Home > PHP

替换帖子里面的网址成可点击的链接

linker   ·   发表于 3个月前   ·   PHP
function makeClickableLinks($text) {
//$text = preg_replace('/^((http|https)://[-a-zA-Z0-9@:%_+.~#?&//=]+)(\s+)/i', '<a href="$1">$1</a>', $text);
$text = preg_replace('/(http|ftp|https):\/\/([\w\d\-_]+[\.\w\d\-_]+)([:\d+]?)([\/]?[\w\/\.\?=&;%@#+-,]+)/i', '<a href="$1://$2$3$4">链接=>$4</a>', $text);
return $text;
}
0 Reply   |  Until 3个月前 | 48 View
LoginCan Publish Content