[dx] Posted July 4, 2009 Share Posted July 4, 2009 Hellow, How to replace some link in message from db? Let say I have $row['body'] which reads body message from database and want to replace www.something.net to <a href="www.something.net">www.something.net</a> etc.I know to do that If I already know which link will be replaced, but if user posts some other link..Thanks Link to comment Share on other sites More sharing options...
smerny Posted July 4, 2009 Share Posted July 4, 2009 http://www.croncast.com/search/1205/Make-l...reate-links.phpfunction makeURL($URL) {$URL = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:\+.~#?&//=]+)','<a href=\\1>\\1</a>', $URL);$URL = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:\+.~#?&//=]+)','<a href=\\1>\\1</a>', $URL);$URL = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})','<a href=\\1>\\1</a>', $URL);return $URL;} Link to comment Share on other sites More sharing options...
[dx] Posted July 5, 2009 Author Share Posted July 5, 2009 Thanks smerny Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.