<?php
$ar=array();
$d=dir(".");
while($f=$d->read()){
$ar['name'][]=$f;
$ar['type'][]=is_dir($f)?"dir":"file";
$ar['time'][]=date("Y-m-dH:i:s",filectime($f));
$ar['size'][]=filesize($f);
}
$d->close();
array_multisort($ar['type'],$ar['name'],SORT_STRING,SORT_ASC,$ar['time'],SORT_DESC,$ar['size']);
echo"<table>";
foreach($ar['name']as$k=>$v)
printf("<tr><td>%s</td><td>%s</td><td>%d</td><td>%s</td></tr>",$v,$ar['type'][$k]=="dir"?"[DIR]":"",$ar['size'][$k],$ar['time'][$k]);
echo"</table>";
?>
返回结果如下:
.[DIR]02004-08-1609:13:51
..[DIR]02004-07-2915:27:34
admin[DIR]02004-08-1609:13:51
db[DIR]02004-08-1609:13:51
includes[DIR]02004-08-1609:13:51
install[DIR]02004-08-1609:13:52
language[DIR]02004-08-1609:13:52
templates[DIR]02004-08-1609:13:52
admin_login.php77652004-08-1609:13:51
common.php40992004-08-1609:13:51
config.php2592004-08-1609:28:24
extension.inc7572004-08-1609:13:51
redme.doc107522004-08-1609:13:52
test.php9072004-08-1609:13:52
test2.php3382004-09-2215:10:00
设计说明文档.txt3692004-08-1609:13:52