我不太确定你想要什么,但这是一个猜测。如果它的最后一个字符是,你能测试找到的条目是一个文件夹/
吗?
新的文件夹.zip 内容
New folder/New folder/New folder/New Text Document (2).txt
New folder/New folder/New folder/New Text Document.txt
New folder/New folder/New Text Document.txt
编码
$zip = zip_open('New folder.zip');
$dirs = $files = array();
if ($zip) {
while ($zip_entry = zip_read($zip)) {
$zen = zip_entry_name($zip_entry);
$is_dir = substr($zen, -1) == DIRECTORY_SEPARATOR;
$zen_splitted = explode(DIRECTORY_SEPARATOR, $zen);
if ($is_dir) {
$dirs[] = $zen_splitted[count($zen_splitted)-2];
} else {
$files[] = $zen_splitted[count($zen_splitted)-1];
}
}
zip_close($zip);
}
print_r($dirs);
print_r($files);
输出
Array
(
[0] => New folder
[1] => New folder
[2] => New folder
[3] => New folder (2)
)
Array
(
[0] => New Text Document (2).txt
[1] => New Text Document.txt
[2] => New Text Document.txt
)