Python Forum

Full Version: PHP Gallery sorting by newest file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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);
array_multisort($files, SORT_DESC, $times);
return $files;
Is this more related to Python than it looks at first glance? Or did you post on the wrong forum?
You sir are absolutely right, wrong forum indeed. lol