If you need to sort, build an array and sort that.
$files = array();
$dir = new DirectoryIterator('.');
foreach ($dir as $fileinfo) {
$files[$fileinfo->getMTime()][] = $fileinfo->getFilename();
}
ksort($files);
This will build an array with the modified time as the key and an array of filenames as the value. It then sorts via ksort()
, which will give you the filenames in order of time modified.
If you then want to re-flatten the structure to a standard array, you can use...
$files = call_user_func_array('array_merge', $files);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…