[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

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

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
movieprodw
Asked:
movieprodw
1 Solution
 
Terry WoodsIT GuruCommented:
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
 
movieprodwAuthor Commented:
Awesome!
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now