Return to Snippet

Revision: 5868
at April 9, 2008 18:39 by jaytee


Updated Code
preg_replace("/http:\/\/([^\/]+)[^\s]*/", "<a href='$0'>$1</a>", $text);

Revision: 5867
at April 9, 2008 17:48 by jaytee


Initial Code
preg_replace("/http:\/\/([^\/]+)[^\s]*/", "<a href='$0'>$1<?a>", $text);

Initial URL

                                

Initial Description
Worst title ever.  Basically, this takes a string like:
"Check this out: http://snipplr.com/view/5759/replace-a-url-its-domain-name-and-create-link/" and replaces it with "Check this out: snipplr.com [with a link to the full URL]"

Initial Title
Replace a URL with its domain name and create link

Initial Tags
regex, url

Initial Language
PHP