Skip to content

Instantly share code, notes, and snippets.

@LaffinToo
Created December 8, 2011 08:52
Show Gist options
  • Save LaffinToo/1446496 to your computer and use it in GitHub Desktop.
Save LaffinToo/1446496 to your computer and use it in GitHub Desktop.
Creates links from plain text links (http/https/ftp/mailto/telnet)
function linkify($matches)
{
return '<a class="link" href="'. $matches[1] .'" target="_blank">'. $matches[4] .'</a>';
}
$pr = preg_replace_callback('@((https?|ftp|mailto|telnet):(//)?([^\s]{4,}))@i','linkify',$line);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment