List directory contents by date

Loads the contens of a dir an sorts them by the date of creation.
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; } //Example: listdir_by_date('data/');

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

Language: PHP | User: ShareMySnippets | Created: Oct 16, 2013