I currently have a script which allows me to output the list of files inside the same directory.
The output shows the names, and then I used filemtime()
function to show the date when the file was modified.
How will I sort the output to show the latest modified file?
This is what I have for now:
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$lastModified = date('F d Y, H:i:s', filemtime($file));
if(strlen($file)-strpos($file, ".swf") == 4) {
echo "$file - $lastModified";
}
}
}
closedir($handle);
}