龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

php网址转换为超链接方法

时间:2014-07-22 14:52来源: 作者: 点击:
分享到:
pphp网址转换为超链接方法br / a href=http://hi.baidu.com/9958ing/bloghttp://hi.baidu.com/9958ing/blog/a/p

php网址转换为超链接方法
http://hi.baidu.com/9958ing/blog


function showtext($text){
	$search = array('|(http://[^ ]+)|', '|(https://[^ ]+)|', '|(www.[^ ]+)|');
	$replace = array('<a href="$1" target="_blank">$1</a>', '<a href="$1" target="_blank">$1</a>', '<a href="http://$1" target="_blank">$1</a>');
	$text = preg_replace($search, $replace, $text);
	return $text;
}
精彩图集

赞助商链接