Function - link it

Post Reply
MrCambron
Posts: 13
Joined: Tue Dec 19, 2017 5:34 pm

Function - link it

Post by MrCambron » Wed Jul 11, 2018 8:43 pm

Function: link it.

I am not sure where I got this function from. But looks like something to link urls on like a forum post. This is not my created code because I know that I do not structure the brackets that way.

Code: Select all

function link_it($text)  
{  
    $text= preg_replace("/(^|[\n ])([\w]*?)((ht|f)tp(s)?:\/\/[\w]+[^ \,\"\n\r\t<]*)/is", "$1$2<a href=\"$3\" >$3</a>", $text);  
    $text= preg_replace("/(^|[\n ])([\w]*?)((www|ftp)\.[^ \,\"\t\n\r<]*)/is", "$1$2<a href=\"http://$3\" >$3</a>", $text);  
    $text= preg_replace("/(^|[\n ])([a-z0-9&\-_\.]+?)@([\w\-]+\.([\w\-\.]+)+)/i", "$1<a href=\"mailto:$2@$3\">$2@$3</a>", $text);  
    return($text);  
}

Post Reply