function replaceUrls($str)
{
if(empty($str)){
return $str;
}
$regex = '/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/i';
return preg_replace($regex,'<a href="$1">$1</a>',$str);
}
php匹配字符串中的url并替换为超链接
最新推荐文章于 2024-04-22 14:07:29 发布