简体   繁体   English

通过PHP探索zip存档

[英]exploring zip archive by PHP

this my code 这是我的代码

$z = new ZipArchive();

if ($z->open('file.zip')) {

            for ($i=0; $i<$z->numFiles;$i++) {
                $aZipDtls = $z->statIndex($i);
                echo $aZipDtls['name'].'<br>';

            }
     }

it returns 它返回

docs/
docs/INSTALL.html
docs/auth_api.html
docs/install/
docs/install/index.htm

but i want it return a files tree like that 但我希望它返回这样的文件树

docs/
 -INSTALL.html
 -auth_api.html
  install
   -index.htm 

to make it ul and li and i want to do this do use the PHP File Tree 使它成为ul和li,我想使用PHP File Tree做到这一点

You'll have to work that out manually. 您必须手动解决。 The zip archive stores the files in a very flat structure, but has knowledge of the structure required when "unzipping". zip存档以非常扁平的结构存储文件,但是具有“解压缩”时所需的结构知识。

You will have to work out this structure as you go through the archive. 浏览档案时,您将必须确定此结构。 You will need to take a look a string functions to help you do this: 您将需要查看一个字符串函数来帮助您完成此操作:

http://php.net/manual/en/ref.strings.php http://php.net/manual/en/ref.strings.php

Perhaps you could use this library, I think it supports listing content. 也许您可以使用此库,我认为它支持列表内容。 http://www.phpconcept.net/pclzip/man/en/index.php http://www.phpconcept.net/pclzip/man/en/index.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM