I need to filter some files from a directory containing many files. During my script, this function is called many times.
function getFilteredFiles($criteria) {
static $files = '';
if ($files == '') {
$files = new DirectoryIterator($path);
}
else {
$files->rewind();
}
foreach($files as $file) {
if (! $file->isDot()) {
if (!$file->isDir()) {
...
}
}
}
...
}
Put DirectoryIterator in a static variable to allow php to go to the file system only once to get the files? (= Does php only work on the file system during the __ DirectoryIterator construct?)
murze source
share