$str = file_get_contents('text.txt'); preg_match_all('/[zzz][0-9]"/',$str,$found); foreach( $found as $s) { echo $s."\n"; }