php - 如何在根文件夹的顶部对最新的文本文件内容进行排序和显示
问题描述
无法有效地对一批文本文件和内容进行排序并显示最新到旧。
我试过 natsort ($directory);
<?php
$directory = "feeds/";
$dir = opendir($directory);
while (($file = readdir($dir)) !== false) {
$filename = $directory . $file;
$type = filetype($filename);
if ($type == 'file') {
$contents = file_get_contents($filename);
$items = explode('\n', $contents);
echo '<table width="100%" border="1"
cellpadding="4" bgcolor="#fff" id="rcorners">';
foreach ($items as $item) {
echo"<tr><td id='rcorners'>".nl2br
($item)."</td></tr>\n";
}
echo '</table>';
}
}
closedir($dir);
?>
没有错误只是不要从最新到最旧排序。
解决方案
推荐阅读
- php - 如果我给出负偏移量,stripos 将不起作用
- visual-studio - 无法使用 Bower 在 Visual Studio 2017 中安装 jQuery(或其他 Bower 包)
- sqlite - EF Core 中每隔一个数据行就有一个空关系
- ios - 为什么没有向我建议“keychainwrapper”和“FIRAuth”并着色?
- r - 仅在绘制条形图时才在条形图中显示班级计数
- java - Web 应用程序中的 Appium:无法在通知弹出窗口中点击允许权限按钮
- javascript - 范围输入上的“指针事件:无”
- json - 如何在 Neo4j 中插入 JSON 批量数据?
- java - 从 Java 中的文本文件中读取完全匹配数据
- c++ - 为 C++ 代码创建 R 包时引用 boost 库