set_time_limit(0); $lines = file('mail.txt'); $out = array(); foreach ($lines as $line_num => $line) { $url=file_get_contents(trim($line)); preg_match_all('/[.-_A-Za-z0-9]+?@[.-A-Za-z0-9]+ ?[.A-Za-z0-9]{2,}/', $url, $out); echo $line.' '; print_r($out); echo ''; }