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

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

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

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

        <tfoot id='Q2M9h'></tfoot>

        使用php扫描目录和子目录中的文件并将其路径存储在数组中

        Scan files in a directory and sub-directory and store their path in array using php(使用php扫描目录和子目录中的文件并将其路径存储在数组中)
            <tbody id='dcFiX'></tbody>
        • <i id='dcFiX'><tr id='dcFiX'><dt id='dcFiX'><q id='dcFiX'><span id='dcFiX'><b id='dcFiX'><form id='dcFiX'><ins id='dcFiX'></ins><ul id='dcFiX'></ul><sub id='dcFiX'></sub></form><legend id='dcFiX'></legend><bdo id='dcFiX'><pre id='dcFiX'><center id='dcFiX'></center></pre></bdo></b><th id='dcFiX'></th></span></q></dt></tr></i><div id='dcFiX'><tfoot id='dcFiX'></tfoot><dl id='dcFiX'><fieldset id='dcFiX'></fieldset></dl></div>

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

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

                <tfoot id='dcFiX'></tfoot>

                1. <legend id='dcFiX'><style id='dcFiX'><dir id='dcFiX'><q id='dcFiX'></q></dir></style></legend>
                  本文介绍了使用php扫描目录和子目录中的文件并将其路径存储在数组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我不想扫描目录及其子目录中的所有文件.并在数组中获取它们的路径.就像数组中目录中文件的路径将只是

                  I want not scan all the files in a directory and its sub-directory. And get their path in an array. Like path to the file in the directory in array will be just

                  路径 -> text.txt

                  path -> text.txt

                  而子目录中文件的路径为

                  while the path to a file in sub-directory will be

                  somedirectory/text.txt

                  somedirectory/text.txt

                  我可以扫描单个目录,但它返回所有文件和子目录,无法区分.

                  I am able to scan single directory, but it returns all the files and sub-directories without any ways to differentiate.

                      if ($handle = opendir('fonts/')) {
                      /* This is the correct way to loop over the directory. */
                      while (false !== ($entry = readdir($handle))) {
                          echo "$entry<br/>";
                      }
                  
                  
                      closedir($handle);
                      }
                  

                  获取目录和子目录中所有文件及其路径的最佳方法是什么?

                  What is the best way to get all the files in the directory and sub-directory with its path?

                  推荐答案

                  使用 SPL 中的 DirectoryIterator 可能是最好的方法:

                  Using the DirectoryIterator from SPL is probably the best way to do it:

                  $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.'));
                  foreach ($it as $file) echo $file."
                  ";
                  

                  $file 是一个 SPLFileInfo-object.它的 __toString() 方法将为您提供文件名,但还有其他几种方法也很有用!

                  $file is an SPLFileInfo-object. Its __toString() method will give you the filename, but there are several other methods that are useful as well!

                  更多信息参见:http://www.php.net/manual/en/class.recursivedirectoryiterator.php

                  这篇关于使用php扫描目录和子目录中的文件并将其路径存储在数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  • <tfoot id='GjseD'></tfoot>
                      • <bdo id='GjseD'></bdo><ul id='GjseD'></ul>

                      • <legend id='GjseD'><style id='GjseD'><dir id='GjseD'><q id='GjseD'></q></dir></style></legend>
                          <tbody id='GjseD'></tbody>

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

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