Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PHP: Add url to text
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
You can’t perform that action at this time.