如何以“最后修改日期”顺序列出目录中的文件? (Linux 上的 PHP5)
最佳答案
function newest($a, $b)
{
return filemtime($a) - filemtime($b);
}
$dir = glob('files/*'); // put all files in an array
uasort($dir, "newest"); // sort the array by calling newest()
foreach($dir as $file)
{
echo basename($file).'<br />';
}
信用 goes here .
关于PHP:有序目录列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2428795/