A cleaner (I think) way to sort a list of files into reversed order based on their modification date.<?php $path = $_SERVER[DOCUMENT_ROOT]."/files/"; $dh = @opendir($path); while (false !== ($file=readdir($dh))) { if (substr($file,0,1)!=".") $files[]=array(filemtime($path.$file),$file); #2-D array } closedir($dh); if ($files) { rsort($files); #sorts by filemtime #done! Show the files sorted by modification date foreach ($files as $file) echo "$file[0] $file[1]<br>\n"; #file[0]=Unix timestamp; file[1]=filename }?>