当前位置:首页 >> 网络编程

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

编辑:jimmy
  日期: 2025/2/5 浏览:1 次
复制代码 代码如下:
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中PDO的错误处理
下一篇: php ajax 静态分页过程形式