<?php $d='du/'; $da=scandir($d); $ar=array(); foreach($da as $str) { if(is_file($d.$str) && substr($str,-1)=='t' && preg_match_all('/om\/([^\/]{6,})\//',join(' ',file($d.$str)),$res)){ $ar[]=substr($str,1,4); unset($res[1][0],$res[1][2]); $ar=array_merge($ar,$res[1]); } } echo count($ar).' '; $ar=array_unique($ar); echo count($ar)."\n"; echo join("\n",$ar);