Output of ZipArchive() in tree format

我只是一个虾纸丫 提交于 2019-12-24 08:49:49

问题


Using PHP, I have this list of files, that I get by:

new ZipArchive();

I mean that it is in a zip file.

The file list is:

  • docs/
  • docs/INSTALL.html
  • docs/auth_api.html
  • docs/corners_right.gif
  • docs/corners_right.png
  • docs/COPYING
  • docs/corners_left.png
  • docs/bg_header.gif
  • docs/CHANGELOG.html
  • docs/coding-guidelines.html
  • docs/hook_system.html
  • docs/FAQ.html
  • docs/site_logo.gif
  • docs/AUTHORS
  • docs/README.html
  • docs/corners_left.gif
  • docs/stylesheet.css
  • docs/New Folder/
  • docs/New Folder/New Text Document.txt
  • docs/New Folder/New Folder/

I need a way to cut the dir name from each file path and make it a sub category.

So the output should be like this:

 docs/
  INSTALL.html
  auth_api.html
  corners_right.gif
  corners_right.png
  COPYING
  New Folder/
    New Text Document.txt
    New Folder/
      New Folder/ 

I hope it's not impossible


回答1:


use split('/',path) or preg_split (for php 6) the documentation (with examples) can be found here: http://www.php.net/manual/en/function.split.php and http://www.php.net/manual/en/function.preg-split.php



来源:https://stackoverflow.com/questions/1872794/output-of-ziparchive-in-tree-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!