Solved

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

Posted on 2014-03-02
2
267 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Button Click 11 25
Connect MySql database to wordpress site 3 15
MySQL ERROR 1045 (28000) 2 39
XML Data Missing in PHP SimpleXML 8 21
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

708 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

17 Experts available now in Live!

Get 1:1 Help Now