我只有以下代码,并将print_r
输出留给您了解发生了什么:
$z = new ZipArchive;
$folder_to_delete = "gifresizer/resized/"; //folder to delete relative to root
if($z->open("gifresizer.zip")===TRUE){ //zip file name
print_r($z);
for($i=0;$i<$z->numFiles;$i++){
$entry_info = $z->statIndex($i);
print_r($entry_info);
if(substr($entry_info["name"],0,strlen($folder_to_delete))==$folder_to_delete){
$z->deleteIndex($i);
}
}
}
它输出如下内容:
ZipArchive Object
(
[status] => 0
[statusSys] => 0
[numFiles] => 10
[filename] => C:\xampp\htdocs\test\zipdelete\gifresizer.zip
[comment] =>
)
Array
(
[name] => gifresizer/
[index] => 0
[crc] => 0
[size] => 0
[mtime] => 1339360746
[comp_size] => 0
[comp_method] => 0
)
Array
(
[name] => gifresizer/frames/
[index] => 1
[crc] => 0
[size] => 0
[mtime] => 1328810540
[comp_size] => 0
[comp_method] => 0
)
Array
(
[name] => gifresizer/gifresizer.php
[index] => 2
[crc] => 1967518989
[size] => 18785
[mtime] => 1328810430
[comp_size] => 3981
[comp_method] => 8
)
etc..