Skip to content

Instantly share code, notes, and snippets.

@raulsilvamx
Created January 20, 2015 23:59
Show Gist options
  • Save raulsilvamx/5f70e1f3269a59df2b9a to your computer and use it in GitHub Desktop.
Save raulsilvamx/5f70e1f3269a59df2b9a to your computer and use it in GitHub Desktop.
phpEmailExtractor
<?php
/* @author @raulsilvamx
* @create 20/01/2015 11:25:47 AM
* @file phpEmailExtractor.php
*/
//SOURCE FOR EXTRACT EMAILS
$string = file_get_contents("/Users/<USER>/Sites/phplist/Inbox.txt"); // Load text file contents
$pattern = '/[A-Za-z0-9_-]+@[A-Za-z0-9_-]+\.([A-Za-z0-9_-][A-Za-z0-9_]+)/'; //regex for pattern of e-mail address
preg_match_all($pattern, $string, $matches);
$matches = array_unique($matches[0]);
ksort($matches);
var_dump($matches);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment