Skip to content

Instantly share code, notes, and snippets.

@shyamsalimkumar
Last active December 18, 2015 08:19
Show Gist options
  • Save shyamsalimkumar/5752642 to your computer and use it in GitHub Desktop.
Save shyamsalimkumar/5752642 to your computer and use it in GitHub Desktop.
PHP - Automatic mailto links
$pattern = "/([a-z0-9][_a-z0-9.-]+@([0-9a-z][_0-9a-z-]+\.)+[a-z]{2,6})/i";
$replace = "\\1";
$text = preg_replace($pattern, $replace, $stringa);
echo htmlspecialchars($text);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment