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


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

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/a8329413bbc76e849723e0605b298ed3.html