zoukankan      html  css  js  c++  java
  • php获取指定文件夹中文件名称

    /**
         * php获取指定文件夹中文件名称
         * @author jackie <2018.10.10>
         */
        public static function getFileName($filePath)
        {
            $handler = opendir($filePath);//目录文件夹
            $fileNames = [];//存儲文件名稱
            while( ($filename = readdir($handler)) !== false ) {
                if($filename != "." && $filename != ".."){
                    $fileNames[] = $filename;
                }
            }
            closedir($handler);
            return $fileNames;
        }

    方法二

    返回數組格式

    /**
     * php获取指定文件夹下文件名称
     * @param $filePath 目錄文件夾路徑
     * @author jackie <2018.10.10>
     */
    function getFileName($filePath)
    {
    
        $handler = opendir($filePath);//当前目录中的文件夹下的文件夹
        while( ($filename = readdir($handler)) !== false ) {
            if($filename != "." && $filename != ".."){
                $dile_name[] = $filename;
            }
        }
        closedir($handler);
    
        return $dile_name;
    }

    打印結果

    array:3 [▼
      0 => "FU023.cache"
      1 => "FU023.html"
      2 => "FU023data"
    ]
  • 相关阅读:
    对结对编程的测试
    用例
    结对编程 一
    个人项目总结与结对编程的开始
    7-6随便写写
    7-5个人日报
    7-4个人报告
    7.1-7.3个人日报
    6-30个人日报
    6-29个人日报
  • 原文地址:https://www.cnblogs.com/clubs/p/9767937.html
Copyright © 2011-2022 走看看