PHP:有序目录列表

Daw*_*hia 4 php

如何以"上次修改日期"顺序列出目录中的文件?(Linux上的PHP5)

Chr*_*heD 14

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 />'; 
} 
Run Code Online (Sandbox Code Playgroud)

信用就在这里.