$f = @implode('',@file('INPUT.TXT')); if (preg_match_all('/(\w+@\w+\.\w{2,3})/'),$f,$m) { $m = array_unique($m); var_dump($m); }