Jump to content

Str_replace And Links


[dx]
 Share

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;}

Edited by smerny
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...