• PHP遍历某个目录下的所有文件和子文件夹的实现代码



    <?php
     function read_all_dir ( $dir )
        {
            $result = array();
            $handle = opendir($dir);
            if ( $handle )
            {
                while ( ( $file = readdir ( $handle ) ) !== false )
                {
                    if ( $file != '.' && $file != '..')
                    {
                        $cur_path = $dir . DIRECTORY_SEPARATOR . $file;
                        if ( is_dir ( $cur_path ) )
                        {
                            $result['dir'][$cur_path] = read_all_dir ( $cur_path );
                        }
                        else
                        {
                            $result['file'][] = $cur_path;
                        }
                    }
                }
                closedir($handle);
            }
            return $result;
        }
    ?>

  • 相关阅读:
    分享
    慕课网-软件测试基础-学习笔记
    向量内积(点乘)和外积(叉乘)概念及几何意义
    使用opencv3+python实现视频运动目标检测
    解决opencv3运行opencv2代码时报错的修改备忘录
    分享
    OpenCV学习笔记
    LeetCode
    LeetCode
    npm安装包很慢
  • 原文地址:https://www.cnblogs.com/akuo-123/p/8059085.html
Copyright © 2020-2023  润新知