我會希望結合功能找到最近的文件開始:查找最新的文件開始
$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](http://stackoverflow.com/a/2084498/342740)它還包含文件時間的元素。 – Prix