How to replace a URL to an Hyperlink in a String?
17
May
2013

At times you come across a scenario where the string contains an http link and you need to create the hyperlink to the same.

This is can very well achieved using the single line of code.


<?php
$text = “This is http://www.http://paceinfonet.org site”;
echo $text = ereg_replace(“[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]”, “\0“, $text);
?>

  • 705 View
  • Pin It