Sunday, 13 January 2013

How to replace a URL to an Hyperlink in a String?

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.

$text = "This is site";
echo $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "\\0", $text);



No comments:

Post a Comment