If 'http://' in description then make a link

movieprodw
movieprodw used Ask the Experts™
on
Hello,

Is there a way to make it so if there is a link in the php description it will show it as a link?

<?php echo $row['desc']; ?>

Thanks,
Matt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Guru
Most Valuable Expert 2011
Commented:
Something like this?

<?

$data = "The site http://humblebundle.com is awesome, as is http://bitcoin.org !";

print preg_replace("#https?://\S*#","<a href='$0'>$0</a>",$data);

Open in new window


Result:
The site <a href='http://humblebundle.com'>http://humblebundle.com</a> is awesome, as is <a href='http://bitcoin.org'>http://bitcoin.org</a> !

Open in new window

Author

Commented:
Awesome!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial