我尝试使用代码从目录中读取文件名,并将过滤器添加到文件名中包含当前年份和月份的只读文件中
Julius Robles_Client11_20130508_10-42-42_AM.zip
Julius Robles_Client12_20130508_11-45-42_AM.zip
Julius Robles_Client13_20130508_11-58-42_AM.zip
所以代码只会返回名称中包含 201305 的文件,但它会返回正确的过滤集,但有些文件丢失了,我不知道为什么?
还有什么是文件“。” 和“..”存储在数组的前两行?
这是代码
$filenames = array();
if ($handle = opendir('archive/search_logs/')) {
$ctr = 0;
while (false !== ($entry = readdir($handle))) {
//if(strpos($entry,date('Ym')) !== false){
$name = $entry;
$entry = str_replace("-",":",$entry);
$filenames[$ctr] = explode("_", $entry);
$filenames[$ctr][] = $name;
$ctr++;
//}
}
closedir($handle);
}