PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$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;
}
}
}
$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?
$dir = new DirectoryIterator($dataDir);
sort($dir)
foreach ($dir as $file) {.....}
Sorry for asking such a basic question. I have never used any sort functions and also didn't understand that $dir = new DirectoryIterator($dataDir) was creating an array in $dir. If I am missing something or incorrect about any of this please let me know.