quote:
Originally posted by -dt-
its even easier than that...
php code:
<?php
$dir = "D:/";
$toFind = "xxx";
foreach(new DirectoryIterator($dir) as $file){
if(!$file->isDir()){
$ext = trim(strrchr($file, '.'), ".");
if($ext == "txt"){
$fp = fopen($file->getPathname(), 'r');
while($fp && !feof($fp)){
$line = stream_get_line($fp, 2048, "\n");
if(strpos($line, $toFind) !== false){
echo $file . "\n";
}
}
fclose($fp);
}
}
}
?>
Very elegant, I never thought of using foreach to work through each file or even stream_to_get_line! The more you use the more you learn!