如何按时间排序文件夹示例我在目录中创建最后一个/最新文件夹,因此最后一个文件夹显示在顶部。
这是仅显示目录的代码
<?php
function folderlist(){
$startdir = './';
$ignoredDirectory[] = '.';
$ignoredDirectory[] = '..';
if (is_dir($startdir)){
if ($dh = opendir($startdir)){
while (($folder = readdir($dh)) !== false){
if (!(array_search($folder,$ignoredDirectory) > -1)){
if (filetype($startdir . $folder) == "dir"){
$directorylist[$startdir . $folder]['name'] = $folder;
$directorylist[$startdir . $folder]['path'] = $startdir;
}
}
}
closedir($dh);
}
}
return($directorylist);
}
$folders = folderlist();
foreach ($folders as $folder){
$path = $folder['path'];
$name = $folder['name'];
echo '<li><a href="' .$path .'index.php?album=' .$name . '" class="style1"><font face="Tahoma" class="ws10"><B>' . $name . '</B></a><br /></li>';
}
?>