递归目录列表(显示完整目录结构)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了递归目录列表(显示完整目录结构)相关的知识,希望对你有一定的参考价值。

Takes advantage of the SPL. Much easier and maintainable than the previous revisions. Haven't done any benchmarks yet but I imagine it is much faster. "If you want to omit directories, remove the RecursiveIteratorIterator::SELF_FIRST part."
  1. <?php
  2. $path = realpath('/etc');
  3.  
  4. $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
  5. foreach($objects as $name => $object){
  6. echo "$name ";
  7. }
  8. ?>

以上是关于递归目录列表(显示完整目录结构)的主要内容,如果未能解决你的问题,请参考以下文章

异步和递归目录扫描,用于 Nodejs 和 Expressjs 中的文件列表

如何执行完整的递归目录和文件扫描?

获取递归包含在目录中的文件列表的最快方法是啥?

包含可折叠递归目录列表的 HTML

ASP对指定文件夹内文件列表显示

数据结构快排专题