zoukankan      html  css  js  c++  java
  • 获取一个目录下的所有文件

    知道一个目录的路径,使用递归获取该目录下的所有文件:

    function rDir($filepath)
    {
      $result = array();//获取的结果保存在这个数组中
      if(is_dir($filepath))
      {
        $re = opendir($filepath);
        while (($file=readdir($re)) != false)
        {
          if ($file != '.' && $file != '..')
          {
            $curpath = $filepath.'/'.$file;
            if (is_dir($curpath))
            {
              $func = __FUNCTION__;
              $res = $func($curpath);
              $result[$file]=$res;
            }

            else
            {
              $result[]=$file;
            }
          }
        }
        closedir($re);
        return $result;
      }
      else if(is_file($filepath))
      {
        return '这个是文件,不是目录';
      }
      else
      {
        return '这是什么东西?';
      }
    }

  • 相关阅读:
    MTGA天梯利用Ummored Ego进行针对核心卡列表
    三日狂欢_THDN_简介
    Unity_Dungeonize 随机生成迷宫
    Match3 Module For Game(THDN)
    UNITY->(width*height)style Inventory
    Mysql基本配置以及常见问题
    C++||变量
    c++||OOP
    c++||template
    实用的js函数
  • 原文地址:https://www.cnblogs.com/walksnow/p/6011973.html
Copyright © 2011-2022 走看看