function link_it($text)
{
$text= preg_replace("/(^|[\n ])([\w]*?)((ht|f)tp(s)?:\/\/[\w]+[^ \,\"\n\r\t<]*)/is", "$1$2<a href=\"$3\" target=\"_blank\">$3</a>", $text);
$text= preg_replace("/(^|[\n ])([\w]*?)((www|ftp)\.[^ \,\"\t\n\r<]*)/is", "$1$2<a href=\"http://$3\" target=\"_blank\">$3</a>", $text);
$text= preg_replace("/(^|[\n ])([a-z0-9&\-_\.]+?)@([\w\-]+\.([\w\-\.]+)+)/i", "$1<a href=\"mailto:$2@$3\" target=\"_blank\">$2@$3</a>", $text);
return($text);
}
That's the working code.
I'm working on a new function
function shorturl2full($url)
{
echo 'URL IS: ' . $url;
return "FULLLINK";
}
The idea is to take the url and return it back. Later going to work on turning it in to the full url. So like t.co
will be full url they will see.
$text= preg_replace("/(^|[\n ])([\w]*?)((ht|f)tp(s)?:\/\/[\w]+[^ \,\"\n\r\t<]*)/is", "$1$2<a href=\"$3\" target=\"_blank\">" . shorturl2full("$3") . "</a>", $text);
$text= preg_replace("/(^|[\n ])([\w]*?)((www|ftp)\.[^ \,\"\t\n\r<]*)/is", "$1$2<a href=\"http://$3\" target=\"_blank\">" . shorturl2full("$3") . "</a>", $text);
$text= preg_replace("/(^|[\n ])([a-z0-9&\-_\.]+?)@([\w\-]+\.([\w\-\.]+)+)/i", "$1<a href=\"mailto:$2@$3\" target=\"_blank\">$2@$3</a>", $text);
return($text);
}
Is my bad try at it.
So if you click the link it should use the original but the one you see should be the output of shorturl2full
So like <a href="t.co">FULLLINK</a>
I want to attempt to write the shorturl2full
function on my own and i think i have a very great idea on how to do it. The problem is in the link_it
function... It needs to pass the url to the shorturl2full
function and display what ever it returned.