php中将网址转换为超链接的函数_php教程-查字典教程网
php中将网址转换为超链接的函数
php中将网址转换为超链接的函数
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:functionshowtext($text){$search=array('|(http://[^]+)|','|(ht...

复制代码 代码如下:

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教程学习
    热门php教程学习
    编程开发子分类