php读取目录下的所有文件

Posted 绝技小嗨皮

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php读取目录下的所有文件相关的知识,希望对你有一定的参考价值。


<?php
$path = ‘./use‘;
$result = scanFile($path);
function scanFile($path) {
  global $result;
  $files = scandir($path);
  foreach ($files as $file) {
    if ($file != ‘.‘ && $file != ‘..‘) {
      if (is_dir($path . ‘/‘ . $file)) {
        scanFile($path . ‘/‘ . $file);
      } else {
        $result[] = basename($file);
      }
    }
  }
  return $result;
}

 

 

 

以上是关于php读取目录下的所有文件的主要内容,如果未能解决你的问题,请参考以下文章