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

2019-11-17,,,,

复制代码 代码如下:
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;
}

《php中将网址转换为超链接的函数.doc》

下载本文的Word格式文档,以方便收藏与打印。