【发布时间】:2013-08-05 09:18:03
【问题描述】:
我希望通过共轭函数来查找以以下开头的最新文件:
$path = "/home/www/images/xml_cache";
$nom="images_album_6*.xml";
foreach (glob($path.'/'.$nom.'') as $filename) { }
和
$latest_ctime = 0;
$latest_filename = '';
$d = dir($path);
while (false !== ($entry = $d->read( ))) {
$filepath = "{$path}/{$entry}";
// could do also other checks than just checking whether the entry is a file
if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
}
但是怎么做呢?
提前谢谢你
【问题讨论】:
-
在这个答案help with glob pattern 上使用目录迭代器,它还包含文件时间的元素。