Created
June 24, 2014 01:28
-
-
Save elliotboney/ef26f386d2dd5c54bcb2 to your computer and use it in GitHub Desktop.
Grab emails from a string
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
<?php | |
function extract_emails_from($string){ | |
preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches); | |
return $matches[0]; | |
} | |
// Example useage | |
$text = "blah blah blah [email protected] blah blah blah [email protected]"; | |
$emails = extract_emails_from($text); | |
print(implode("\n", $emails)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment