zoukankan      html  css  js  c++  java
  • php获取文件夹中文件

    使用 scandir函数 可以扫描文件夹下内容

    <?php
    class DirPath{
        function scandirFolder($path)
        {
            $list     = [];
            $temp_list = scandir($path);
            foreach ($temp_list as $file)
            {
                //排除根目录
                if ($file != ".." && $file != ".")
                {
                    if (is_dir($path . "\" . $file))
                    {
                        //子文件夹,进行递归
                        $list[$file] = self::scandirFolder($path . "\" . $file);
                    }
                    else
                    {
                        //根目录下的文件
                        $list[] = $file;
                    }
                }
            }
            return $list;
        }
    }
    
     $dir = new DirPath();
     $res = $dir->scandirFolder(__DIR__.'11');
    echo '<pre>';
        print_r($res);
    echo '<pre>';
  • 相关阅读:
    fastjson 使用方法
    算法
    SHA算法
    MD5算法
    kindle推送服务
    DLL劫持
    Hook编程
    Hook技术
    权限验证
    虚拟机
  • 原文地址:https://www.cnblogs.com/clubs/p/12650183.html
Copyright © 2011-2022 走看看