博士拔了一个拉链,奇怪的行为


Php extracting a zip, strange behaviour

所以我目前在php中面临一个奇怪的行为,这可能很容易解决,但我已经搜索和查找了我的代码1小时或2小时,但我仍然被困在同一个地方。感谢您提前提供的帮助。

这是我的问题

所以我有这个功能

function extractZip($pathToZip, $pathToExtract){
    $zip = new ZipArchive();
    if ($zip->open($pathToZip) === true){
        $zip->extractTo($pathToExtract);
        $zip->close();
    }
    unlink($pathToZip);
}

我把它和一个像一样的拉链一起使用

/folder1/folder2/folder3/files

问题是当我把它提取出来的时候extractZip("path/to/zip.zip","path/to_extract");

结构变得怪异

/folder1/folder2/folder3/files -> this is fine
/folder2/folder3 -> this is weird because it recreates all the folders
and they are empty, but I don't want those useless folder!

谢谢,如果有什么不清楚的地方,只需提问

将php升级到最新版本更正了问题,(php 5.6)