foreach ($files as $file) {
$classResult = array();
$idResult = array();
if (file_exists($file) && is_readable($file)) {
$fh = @fopen($file, "r");
if ($fh) {
while (($line = fgets($fh, 40960000)) !== false) {
if (!empty($line)) :
preg_match_all('/class=["\'](.*)["\']/isU', $line, $result);
if ( !empty($result[1]) )
$classResult = array_merge($result[1], $classResult);
preg_match_all('/id=["\'](.*)["\']/isU', $line, $result);
if ( !empty($result[1]) )
$idResult = array_merge($result[1], $idResult);
endif;
}
fclose($fh);
}
}
}