有关array_multisort的使用
$dir_name="../upload/Study";
$dir = opendir($dir_name);
$basename = basename($dir_name);
$fileArr = array();
while ($file_name = readdir($dir))
{
//Get file modification date
$fName = "$dir_name/$file_name";
$file_isdir = is_dir($fName);
$fTime = filemtime($fName);
$fileArr[]=array("name"=>$file_name,"isdir"=>$file_isdir,"time"=>date("Y-M-d H:i:s",$fTime));
}
foreach ($fileArr as $key => $row)
{
$isdir[$key] = $row['isdir'];
$time[$key] = $row['time'];
$name[$key]=$row['name'];
}
array_multisort($isdir,SORT_DESC,$time,SORT_DESC,$fileArr);
echo "<pre>";
print_r($fileArr);
echo "</pre>";die();
closedir ($dir);
?>
$dir = opendir($dir_name);
$basename = basename($dir_name);
$fileArr = array();
while ($file_name = readdir($dir))
{
//Get file modification date
$fName = "$dir_name/$file_name";
$file_isdir = is_dir($fName);
$fTime = filemtime($fName);
$fileArr[]=array("name"=>$file_name,"isdir"=>$file_isdir,"time"=>date("Y-M-d H:i:s",$fTime));
}
foreach ($fileArr as $key => $row)
{
$isdir[$key] = $row['isdir'];
$time[$key] = $row['time'];
$name[$key]=$row['name'];
}
array_multisort($isdir,SORT_DESC,$time,SORT_DESC,$fileArr);
echo "<pre>";
print_r($fileArr);
echo "</pre>";die();
closedir ($dir);
?>