比较麻烦,但是可以实现: :-)<?
//created by deminy on
//last modified by deminy on $dir_name="/path/to/directory"; $dir = opendir($dir_name); 
$basename = basename($dir_name); 
$fileArr = array(); while ($file_name = readdir($dir)) 

if (($file_name !=".") && ($file_name != "..")) 

//Get file modification date... 
$fName = "$dir_name/$file_name"; 
$fTime = filemtime($fName); 
$fileArr[$file_name] = $fTime; 

} # Use arsort to get most recent first 
# and asort to get oldest first 
arsort($fileArr); $numberOfFiles = sizeOf($fileArr); 
for($t=0;$t<$numberOfFiles;$t++) 

$thisFile = each($fileArr); 
$thisName = $thisFile[0]; 
$thisTime = $thisFile[1]; 
$thisTime = date("d M y", $thisTime); 
echo"<b>$thisName</b> $thisTime "; 

closedir ($dir); 
?>those data was found at the following URL:
http://www.php.net/manual/en/function.readdir.php

解决方案 »

  1.   

    那样会将所有文件读出的,能不能先让目录排序,再读,就象windows下的资源管理器,按时间排序?
      

  2.   

    自己做个函数,
    现遍历目录的所有文件,用数组保存保存filename and filectime
    排序filectime,然后返回filename list
      

  3.   

    其实很简单的,你先运行如dir /od,再返回结果,不就得了。具体不是很难的。我这就不举例了。
      

  4.   

    bill_hongs(hongs):
        还是举一下例子吧!
      

  5.   

    to bill_bongs 
     是先运行exec("dir /od /root/mysite/news/");?
    还是不懂,能举列吗?
      

  6.   

    a sample(在WIN98中测试通过):
    <?php
    unset($strDir);
    exec("dir/od c:\\",$strDir);for($i=0;$i<count($strDir);$i++)
    {
      echo trim($strDir[$i])."<br>";
    }
    ?>
      

  7.   

    但是在liunx下怎么用,用户的最终平台是liunx呀