View Full Version : Make links clickable
03-26-2009, 08: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-26-2009, 11:11 PM
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, 04:32 AM
Here, read this:
03-27-2009, 03: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 © 2017 vBulletin Solutions, Inc. All rights reserved.