I am looking for a code, which I can use for list 5 most recent files recursively in a directory.
Here is a non-recursive code, this one will be perfect for me if it was recursive:
<?php
$show = 0; // Leave as 0 for all
$dir = 'sat/'; // Leave as blank for current
if($dir) chdir($dir);
$files = glob( '*.{html,php,php4,txt}', GLOB_BRACE );
usort( $files, 'filemtime_compare' );
function filemtime_compare( $a, $b )
{
return filemtime( $b ) - filemtime( $a );
}
$i = 0;
foreach ( $files as $file )
{
++$i;
if ( $i == $show ) break;
echo $file . ' - ' . date( 'D, d M y H:i:s', filemtime($file) ) . '<br />' . "\n"; /* This is the output line */
}
?>
It is possible to modify it to scan dirs recursively?