Return to Snippet

Revision: 6760
at June 13, 2008 00:22 by romanos


Initial Code
function listdir_by_date($path){
    $dir = opendir($path);
    $list = array();
    while($file = readdir($dir)){
        if ($file != '.' and $file != '..'){
            // add the filename, to be sure not to
            // overwrite a array key
            $ctime = filectime($data_path . $file) . ',' . $file;
            $list[$ctime] = $file;
        }
    }
    closedir($dir);
    krsort($list);
    return $list;
}

Initial URL
http://www.jonasjohn.de/snippets/php/listdir-by-date.htm

Initial Description
Loads the contens of a dir an sorts them by the date of creation.

Initial Title
List directory contents by date

Initial Tags
date, directory

Initial Language
PHP