Main menu:

Site search

Categories

Archive

How to convert a text URL into a hyperlink

May sound easy, change the HTML….

but there are time when you cannot directly change the HTML.  For instance if your content is database driven, and you don’t want to edit the database source.

well, a little PHP code can do the trick


$str = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $str);

for example This will take a a http://www.attheboard.com and change it to a fully linked tagged link

found this little trick on http://www.liamdelahunty.com

Comments

Trackback from jerawinicexo
Time: March 27, 2010, 7:27 pm

jerawinicexo

Download mp3 with T.O.M Project

Write a comment