Created
July 31, 2015 07:07
-
-
Save RoesWibowo/e320e72a81c15c6a9218 to your computer and use it in GitHub Desktop.
Convert http, https, ftp to link in a text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function convertTextWithLink($text) { | |
$result = preg_replace('%(((f|ht){1}tp[s]?://)[-a-zA-^Z0-9@:\%_\+-.,!~#?&//=]+)%i','<a href="\\1" target="_blank">\\1</a>', $text); | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment