在php中按创建日期对目录文件进行排序 [英] Sorting directory files by creation date in php
本文介绍了在php中按创建日期对目录文件进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我用来获取目录中文件数组的代码.
Here is the code I use to get an array of the files in a directory.
$dir = "thumbnails/";
$images = scandir($dir);
如何按创建日期对$ images数组进行排序?我发现了几种方法,但我无法使用它们来处理我的数组.
How can I sort the $images array by creation date? I found a couple of ways but I couldn't get any of them to work with my array.
谢谢
推荐答案
在Windows上,您可以使用获取文件的创建时间. filectime()
.只需将其与文件名一起放入数组中并对数组进行排序即可.
On Windows you can get the creation time of the file with filectime()
. Just put it in an array with the filename and sort the array.
大多数* nix文件系统上都没有存储创建时间.
Creation time is not stored on most *nix filesystems.
这篇关于在php中按创建日期对目录文件进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文