<?php
function replace_url ($content) {
	if (empty($content)) return;

	//给URL地址加上 <a> 链接
	$preg = '/(?:http:\/\/)?([\w.]+[\w\/]*\.[\w.]+[\w\/]*\??[\w=\&\+\%]*)/is';
	$content = preg_replace($preg, '<a href="http://\1" target="_blank">\1</a>', $content);

	return $content;
}

echo replace_url('百度:http://blog.csdn.net/moqiang02');
?>

相关文章:

  • 2022-12-23
  • 2021-05-14
  • 2021-06-17
  • 2022-02-03
  • 2022-03-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案