Jun-18-2018, 03:49 AM
Php Gallery
Found this neat php gallery, but im trying to get it to display the newest pictures first. The files are already being named by date so i think this should be doable. By newest picture i mean by creation time. And i would really appreciate some help here.
Found some posts about it referring to this function, but im struggling to incorporate it.
Found this neat php gallery, but im trying to get it to display the newest pictures first. The files are already being named by date so i think this should be doable. By newest picture i mean by creation time. And i would really appreciate some help here.
Found some posts about it referring to this function, but im struggling to incorporate it.
function get_files($images_dir,$exts = array('jpg')) { $files = array(); $times = array(); if($handle = opendir($images_dir)) { while(false !== ($file = readdir($handle))) { $extension = strtolower(get_file_extension($file)); if($extension && in_array($extension,$exts)) { $files[] = $file; $times[] = filemtime($images_dir . '/' . $file); } } closedir($handle); } array_multisort($files, SORT_DESC, $times); return $files; }