List directory contents by date


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. function listdir_by_date($path){
  2. $dir = opendir($path);
  3. $list = array();
  4. while($file = readdir($dir)){
  5. if ($file != '.' and $file != '..'){
  6. // add the filename, to be sure not to
  7. // overwrite a array key
  8. $ctime = filectime($data_path . $file) . ',' . $file;
  9. $list[$ctime] = $file;
  10. }
  11. }
  12. closedir($dir);
  13. krsort($list);
  14. return $list;
  15. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.