php中将网址转换为超链接的函数
时间:2021-04-15 11:15:33|栏目:PHP代码|点击: 次
复制代码 代码如下:
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;
}
上一篇:hadoop中一些常用的命令介绍
栏 目:PHP代码
本文标题:php中将网址转换为超链接的函数
本文地址:http://www.codeinn.net/misctech/101382.html






