您的位置:首页 > 编程语言 > PHP开发

php中将网址转换为超链接的函数

2011-09-02 00:00 381 查看
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; 
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐