以树格式输出 ZipArchive() [英] Output of ZipArchive() in tree format
本文介绍了以树格式输出 ZipArchive()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 PHP,我有这个文件列表,我得到了:
Using PHP, I have this list of files, that I get by:
new ZipArchive();
我的意思是它在一个 zip 文件中.
I mean that it is in a zip file.
文件列表为:
- 文档/
- docs/INSTALL.html
- docs/auth_api.html
- docs/corners_right.gif
- docs/corners_right.png
- 文档/复制
- 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/README.html
- docs/corners_left.gif
- docs/stylesheet.css
- 文档/新建文件夹/
- docs/新文件夹/新文本文档.txt
- 文档/新建文件夹/新建文件夹/
我需要一种方法来从每个文件路径中剪切目录名称并将其设为子类别.
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/
我希望这不是不可能的
推荐答案
使用 split('/',path)
或 preg_split
(对于 php 6)文档(示例)可以在这里找到:http://www.php.net/手册/en/function.split.php 和 http://www.php.net/manual/en/function.preg-split.php
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
这篇关于以树格式输出 ZipArchive()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文