DirectoryIterator question
Posted: Tue Mar 18, 2008 1:46 pm
Does anyone know how to sort the return values from DirectoryIterator without first putting it in an array?
$comp DOES NOT necessary come out sorted by modified time. For the most part it does but not always for some unknown (to me) reason. I know I could store $comp in an array and sort the array but is there a way to sort the "foreach ($dir as $file)" part of the code?
Code: Select all
$days=funcToCheckHistory();
for ($i=1,$daysGoingBack=$days;$i<(($days-1)+2);$i++,$$daysGoingBack--) {
$dataDir =
$filepath.date('Ymd', mktime(0, 0, 0,
date("m"),
date("d")-$daysGoingBack,
date("y"))).$fpath;
$dir = new DirectoryIterator($dataDir);
foreach ($dir as $file) {
if (!$dir->isDot()) {
$comp = date($file->getMTime());
// do something with $comp
// I could put it in an array here
array[]= $comp;
}
}
}