Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-26-2009, 08:39 PM   PM User | #1
levani
Regular Coder

 
levani's Avatar
 
Join Date: Mar 2009
Location: Georgia
Posts: 183
Thanks: 29
Thanked 1 Time in 1 Post
levani is an unknown quantity at this point
Make links clickable

Hi

This is the php code which retrieves some data from database:

PHP Code:
echo nl2br($wyaro) . "<br />" nl2br($comment->extra_wyaro); 
How can I make all links which startes from http:// clickable?

Thanks
levani is offline   Reply With Quote
Old 03-26-2009, 11:11 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
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.
__________________
Fumigator is offline   Reply With Quote
Users who have thanked Fumigator for this post:
levani (03-27-2009)
Old 03-27-2009, 04:32 AM   PM User | #3
sea4me
Regular Coder

 
sea4me's Avatar
 
Join Date: Jan 2009
Location: Damn, I don't know...
Posts: 389
Thanks: 11
Thanked 27 Times in 26 Posts
sea4me is an unknown quantity at this point
Here, read this:

http://prajapatinilesh.wordpress.com...nd-short-down/
__________________
sea4me is offline   Reply With Quote
Old 03-27-2009, 03:37 PM   PM User | #4
levani
Regular Coder

 
levani's Avatar
 
Join Date: Mar 2009
Location: Georgia
Posts: 183
Thanks: 29
Thanked 1 Time in 1 Post
levani is an unknown quantity at this point
Thanks a lot for help!!!

This code does this job perfect
PHP Code:
https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?

PHP ExampleAutomatically link URL's inside text.

$text = preg_replace('
@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $text); 
Website: http://snipplr.com/view/2371/regex-r...o-match-a-url/
levani is offline   Reply With Quote
Reply

Bookmarks

Tags
http, links, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:30 PM.


Advertisement
Log in to turn off these ads.