We have 41 guests online
PHP Scripts arrow Free PHP Tutorials arrow Free PHP Tutorials arrow PHP Tutorials and Examples arrow PHP 
Free PHP Tutorials arrow PHP Tutorials and Examples arrow PHP

Converting URLs to anchor tags
User Rating: / 1
PoorBest 

Using preg_replace to convert non-anchored URLs into HTML hyperlinks.

  1. <?php
  2.    $text = "This is a link to http://www.wjgilmore.com/.";
  3.    echo preg_replace("/http://(.*)//", "<a href='${0}'>${0}</a>", $text);
  4.  
  5.    // from "Beginning PHP 5 and MySQL: From Novice to Professional", courtesty apress.com
  6. ?>

 

 

Directory Stats

There are 1036 listing and 46 categories in our website

Change Language