binoymv Posted October 13, 2008 Share Posted October 13, 2008 Hi friends , How to find last latest10 file that are modified. I have a folder named test. In that i am uploading files , i need to take 10 latest file name that are modified. jhow can i do that . I used filemtime for this one , but in this file modified time is showing but this is not a sorted , how can i sort it by latest modified. Thanks in advance Binoy Link to comment https://forums.phpfreaks.com/topic/128252-10-latest-modified-file-name/ Share on other sites More sharing options...
ratcateme Posted October 13, 2008 Share Posted October 13, 2008 try something like this <?php $files = glob("*.*"); $times = array(); foreach($files as $filename){ $times[] = array(filemtime($filename),$filename); } rsort($times); foreach($times as $key => $details){ if($key > 9){ break; } echo "{$details[1]} modified at ". date("F d Y H:i:s.", $details[0])."<br>"; } ?> Scott. Link to comment https://forums.phpfreaks.com/topic/128252-10-latest-modified-file-name/#findComment-664295 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.