This snippet sorts an array of file references by the last changed date of the file by retriving an array of dates and then using array_multisort to sort the array of filenames by the array of dates
PHP Code:
if ($galFiles != NULL) {
sort ($galFiles);
reset ($galFiles);
if ($filesort == "chrono") {
//Sort the images chronologically
foreach ($galFiles as $file) {
$fileloc = getcwd() . "/" . $path_to_imgs . $currDir . $file;
$galfilemod[] = filectime($fileloc);
}
reset ($galFiles);
array_multisort($galfilemod, SORT_DESC, $galFiles) ;
reset ($galFiles);
}
}