【问题标题】:Output of ZipArchive() in tree formatZipArchive() 以树格式输出
【发布时间】:2010-12-24 18:34:17
【问题描述】:

使用 PHP,我得到了以下文件列表:

new ZipArchive();

我的意思是它在一个 zip 文件中。

文件列表为:

  • 文档/
  • 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/新建文件夹/
  • docs/New Folder/New Text Document.txt
  • docs/新建文件夹/新建文件夹/

我需要一种方法从每个文件路径中删除目录名称并使其成为子类别。

所以输出应该是这样的:

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

我希望这不是不可能的

【问题讨论】:

  • 只是为了在文件系统中显示或进一步处理?
  • 因为我希望任何人解决它
  • stackoverflow.com/a/11548872/110488 有一个针对类似问题的通用解决方案,可能会给您一些见解。

标签: php tree text-processing


【解决方案1】:

使用 split('/',path)preg_split(对于 php 6)文档(带有示例)可以在这里找到:http://www.php.net/manual/en/function.split.phphttp://www.php.net/manual/en/function.preg-split.php

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多