sort folder inside directory based on modified date and time
by kalai[ Edit ] 2010-03-02 20:27:15
$from = "path/to/your/directory";
$handle=opendir($from);
$actuafile = array();
while (($filename = readdir($handle))!=false)
{
if (!is_dir($from."/".$filename))
{
$actuafile[count($actuafile)]=$filename;
}
}
closedir($handle);
sort($actuafile); //this is only needed if you want to order files
Another method
// Grab all files from the desired folder
$files = glob( './minutes/*.*' );
// Sort files by modified time, latest to earliest
// Use SORT_ASC in place of SORT_DESC for earliest to latest
array_multisort(
array_map( 'filemtime', $files ),
SORT_NUMERIC,
SORT_DESC,
$files
);
// do whatever you want with $files
print_r( $files );