Jump to content

Str_replace And Links


[dx]

Recommended Posts

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

http://www.croncast.com/search/1205/Make-l...reate-links.php
function 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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...