我正在尝试使用 PHP 按修改日期对文件进行排序。
我正在使用filemtime
函数,然后sort
使用以下代码运行:
<?php
$array2 = array();
$images = glob("*.*");
foreach($images as $image) {
echo "Last modified: ".date("F d Y H:i:s.",filemtime($image));
echo "<br>";
array_push($array2,date("F d Y H:i:s.",filemtime($image)));
}
//echo array2;
sort($array2);
echo "<br>";
foreach ($array2 as $ar)
{
echo $ar;
echo "<br>";
}
//$array2[$image] = date("F d Y H:i:s.",filemtime($image));
?>
输出是这样的
Last modified: June 21 2013 15:48:42.
Last modified: June 12 2013 14:43:10.
Last modified: April 09 2013 15:39:13.
Last modified: June 12 2013 14:00:14.
Last modified: June 21 2013 16:08:58.
Last modified: July 15 2013 12:44:28.
Last modified: July 15 2013 12:48:48.
Last modified: July 15 2013 14:42:19.
Last modified: July 15 2013 14:54:48.
Last modified: April 09 2013 15:39:13.
Last modified: June 21 2013 15:34:30.
Last modified: June 21 2013 15:56:32.
April 09 2013 15:39:13.
April 09 2013 15:39:13.
July 15 2013 12:44:28.
July 15 2013 12:48:48.
July 15 2013 14:42:19.
July 15 2013 14:54:48.
June 12 2013 14:00:14.
June 12 2013 14:43:10.
June 21 2013 15:34:30.
June 21 2013 15:48:42.
June 21 2013 15:56:32.
June 21 2013 16:08:58.
在这里你可以看到七月在四月和六月之间
谁能指导我解决这个问题?