Solved

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

Posted on 2014-03-02
2
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

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 …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

740 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