Detect Url And Add Achor-tags Around It
Recently I've developed a mailinglistsystem with PHP. Now, I'd like to make sure that if someone types a URL, the PHP-script detects it and adds the anchor-tags around it. So if I
Solution 1:
I use the following regex:
$link = preg_replace("/(http:\/\/[^\s]+)/", "<a href=\"$1\">$1</a>", $link);
It may not be perfect, but it works in most cases.
Post a Comment for "Detect Url And Add Achor-tags Around It"