<tfoot id='jzZi8'></tfoot>

      <small id='jzZi8'></small><noframes id='jzZi8'>

        <i id='jzZi8'><tr id='jzZi8'><dt id='jzZi8'><q id='jzZi8'><span id='jzZi8'><b id='jzZi8'><form id='jzZi8'><ins id='jzZi8'></ins><ul id='jzZi8'></ul><sub id='jzZi8'></sub></form><legend id='jzZi8'></legend><bdo id='jzZi8'><pre id='jzZi8'><center id='jzZi8'></center></pre></bdo></b><th id='jzZi8'></th></span></q></dt></tr></i><div id='jzZi8'><tfoot id='jzZi8'></tfoot><dl id='jzZi8'><fieldset id='jzZi8'></fieldset></dl></div>
        • <bdo id='jzZi8'></bdo><ul id='jzZi8'></ul>
        <legend id='jzZi8'><style id='jzZi8'><dir id='jzZi8'><q id='jzZi8'></q></dir></style></legend>

        使用 PHP glob 获取文件夹 - 深度无限

        时间:2023-09-23
          <bdo id='Z9w7q'></bdo><ul id='Z9w7q'></ul>

          <tfoot id='Z9w7q'></tfoot>
          <i id='Z9w7q'><tr id='Z9w7q'><dt id='Z9w7q'><q id='Z9w7q'><span id='Z9w7q'><b id='Z9w7q'><form id='Z9w7q'><ins id='Z9w7q'></ins><ul id='Z9w7q'></ul><sub id='Z9w7q'></sub></form><legend id='Z9w7q'></legend><bdo id='Z9w7q'><pre id='Z9w7q'><center id='Z9w7q'></center></pre></bdo></b><th id='Z9w7q'></th></span></q></dt></tr></i><div id='Z9w7q'><tfoot id='Z9w7q'></tfoot><dl id='Z9w7q'><fieldset id='Z9w7q'></fieldset></dl></div>
            <tbody id='Z9w7q'></tbody>
                <legend id='Z9w7q'><style id='Z9w7q'><dir id='Z9w7q'><q id='Z9w7q'></q></dir></style></legend>

                1. <small id='Z9w7q'></small><noframes id='Z9w7q'>

                2. 本文介绍了使用 PHP glob 获取文件夹 - 深度无限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有这个工作函数来查找文件夹并创建一个数组.

                  I have this working function that finds folders and creates an array.

                  function dua_get_files($path)
                  {
                      foreach (glob($path . "/*", GLOB_ONLYDIR) as $filename)
                      {
                          $dir_paths[] = $filename;   
                      }
                      return $dir_paths;
                  }
                  

                  此功能只能查找当前位置上的目录.我想找到子文件夹中的目录路径及其子文件夹等等.

                  This function can only find the directories on the current location. I want to find the directory paths in the child folders and their children and so on.

                  该数组仍应是目录路径的平面列表.

                  The array should still be a flat list of directory paths.

                  输出数组的示例

                  $dir_path[0] = 'path/folder1';
                  $dir_path[1] = 'path/folder1/child_folder1';
                  $dir_path[2] = 'path/folder1/child_folder2';
                  $dir_path[3] = 'path/folder2';
                  $dir_path[4] = 'path/folder2/child_folder1';
                  $dir_path[5] = 'path/folder2/child_folder2';
                  $dir_path[6] = 'path/folder2/child_folder3';
                  

                  推荐答案

                  如果你想递归地处理目录,你应该看看 RecursiveDirectoryIterator.

                  If you want to recursively work on directories, you should take a look at the RecursiveDirectoryIterator.

                  $path = realpath('/etc');
                  
                  $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
                  foreach($objects as $name => $object){
                      echo "$name
                  ";
                  }
                  

                  这篇关于使用 PHP glob 获取文件夹 - 深度无限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PHP 错误:未加括号的 `a ?乙:丙?d : e` 已弃用.使用 下一篇:用 PHP 解析 JSON 数据

                  相关文章

                  最新文章

                    <i id='Ykg95'><tr id='Ykg95'><dt id='Ykg95'><q id='Ykg95'><span id='Ykg95'><b id='Ykg95'><form id='Ykg95'><ins id='Ykg95'></ins><ul id='Ykg95'></ul><sub id='Ykg95'></sub></form><legend id='Ykg95'></legend><bdo id='Ykg95'><pre id='Ykg95'><center id='Ykg95'></center></pre></bdo></b><th id='Ykg95'></th></span></q></dt></tr></i><div id='Ykg95'><tfoot id='Ykg95'></tfoot><dl id='Ykg95'><fieldset id='Ykg95'></fieldset></dl></div>

                  1. <legend id='Ykg95'><style id='Ykg95'><dir id='Ykg95'><q id='Ykg95'></q></dir></style></legend>
                      <tfoot id='Ykg95'></tfoot>

                        <bdo id='Ykg95'></bdo><ul id='Ykg95'></ul>

                      <small id='Ykg95'></small><noframes id='Ykg95'>