View Full Version : Make links clickable
03-26-2009, 09:39 PM
This is the php code which retrieves some data from database:
echo nl2br($wyaro) . "<br />" . nl2br($comment->extra_wyaro);
How can I make all links which startes from http:// clickable?
03-27-2009, 12:11 AM
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.
03-27-2009, 05:32 AM
Here, read this:
03-27-2009, 04:37 PM
Thanks a lot for help!!!
This code does this job perfect
PHP Example: Automatically link URL's inside text.
$text = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $text);
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.