I am looking for code which lists the five most recent files in a directory recursively.
This is non-recursive code, and would be perfect for me if it was recursive:
This is pretty quick and dirty, and untested, but might get you started:
function top5mods($dir) { $mods = array(); foreach (glob($dir . '/*') as $f) { $mods[] = filemtime($f); } sort($mods); $mods = array_reverse($mods); return array_slice($mods, 0, 5); }