Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
Thread: Make links clickable
03-26-2009, 08:39 PM #1
Make links clickable
This is the php code which retrieves some data from database:
echo nl2br($wyaro) . "<br />" . nl2br($comment->extra_wyaro);
03-26-2009, 11:11 PM #2
- Join Date
- Dec 2005
- Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
- Thanked 637 Times in 625 Posts
You're basically asking what is the regex to identify a URL, which has been covered at least a thousand times before. Google "php url regex" and I'm sure you'll find a regex to use. You can also search Coding Forums, as I've seen it discussed a number of times in the past.
Users who have thanked Fumigator for this post:
03-27-2009, 04:32 AM #3
- Join Date
- Jan 2009
- Damn, I don't know...
- Thanked 28 Times in 27 Posts
03-27-2009, 03:37 PM #4
Thanks a lot for help!!!
This code does this job perfect
Website: http://snipplr.com/view/2371/regex-r...o-match-a-url/PHP Code:
PHP Example: Automatically link URL's inside text.
$text = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $text);