Sort files by date in a specific directory

Uses ksort() to sort files by date/time in a specified directory. Read more.

php
fork add to bundle source
function list_files_by_date($directory) { $files = []; if ($handle = opendir($directory)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $files[$file] = filemtime($file); } } closedir($handle); asort($files); return array_keys($files); } }

usage

load_function('list_files_by_date'); $list = list_files_by_date('/tmp/files'); print_r($list); // Array // ( // [0] => latest_file.txt // [1] => first_file.txt // )
← how to use this in app?
create log ...inout