3
现在默认情况下,它显示的字母表我不想那样。我想通过使用RecursiveDirectoryIterator顶部的最新文件来排序文件。按降序排列。按日期排序文件最新在顶部使用RecursiveDirectoryIterator
还可以使用如果条件从该日起比较日期&获取文件
<?php
$search_path = 'D:\xampp\htdocs';
$file_extension = 'php';
$it = new RecursiveDirectoryIterator("$search_path");
$display = Array ($file_extension);
foreach(new RecursiveIteratorIterator($it) as $file) {
$test = Array();
$test = explode("/",date("m/d/Y",filemtime($file)));
$year = $test[2];
$day = $test[1];
$month = $test[0];
if (in_array(strtolower(array_pop(explode('.', $file))), $display))
if(($year >= 2014) && ($month >= 1) && ($day >= 15)){
echo "<span style='color:red;'>";
echo "<b style='color:green;'>".$day.'-'.$month.'-'.$year. '</b> ' . $file."</span><br>";
}
}
?>
谢谢你,完美的作品。 我实际上在数据项目上存储了另一个参数,所以我可以按此排序。 – 2017-12-06 09:55:26