We have 28 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: / 0
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 702 listing and 43 categories in our website

Change Language

Loans
Hotels
Discount Magazine Subscriptions
MPAA
Mortgage Calculator