Created
April 18, 2014 18:06
-
-
Save morales2k/11056916 to your computer and use it in GitHub Desktop.
Function to make links inside blobs of text by matching urls and replacing them with the links... includes support for cyrilic characters... still has some quirks to work out... but it works on pretty much all cases as far as I have tested it... feel free to suggest improvements! :)
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
function make_links($text, $class='', $target='_blank'){ | |
return preg_replace('!((http\:\/\/|ftp\:\/\/|https\:\/\/)|www\.)([-a-zA-Zа-яА-Я0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?!ism', '<a class="'.$class.'" href="//$3" target="'.$target.'">$1$3</a>', $text); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment