Solved

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

Posted on 2014-03-02
2
270 Views
Last Modified: 2014-03-02
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
0
Comment
Question by:movieprodw
2 Comments
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 39899460
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

0
 
LVL 1

Author Closing Comment

by:movieprodw
ID: 39899497
Awesome!
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now