Created
August 9, 2014 13:43
-
-
Save vienhoang/242bb9e3cf0ea33e595e to your computer and use it in GitHub Desktop.
PHP: Add url to text
This file contains 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
function add_url_to_text( $text ) { | |
// Look for anything that is not a space, i = case insensitive, m = multiple line | |
$text = preg_replace('/(http[^s])+/im', '<a href="$1">$1</a>', $text ); | |
return $text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment