首頁  >  文章  >  後端開發  >  php 获取目录下所有文件实现代码_PHP教程

php 获取目录下所有文件实现代码_PHP教程

WBOY
WBOY原創
2016-07-20 11:09:41850瀏覽

php教程 获取目录下所有文件实现代码
class a{   
 private $img_dir;
        private $img_path;
        private $face_files = array();
        private $allow_extension = array();

private function get_face_files()
        {
            $files = array();
            if(is_dir($this->img_dir))
            {
                if ($dh = opendir($this->img_dir))
                {
                    while (($file = readdir($dh)) !== false)
                    {
                        if($file == '.') continue;
                        if($file == '..') continue;
                        $fileinfo = explode('.', (basename($file)));
                        if(in_array($fileinfo[1], $this->allow_extension))
                        {
                            $files[] = array(
                                'filename' => $fileinfo[0],
                                'extension' => $fileinfo[1],
                            );
                        }
                    }
                    closedir($dh);
                }
            }
            return $files;
        }
}


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/444785.htmlTechArticlephp教程 获取目录下所有文件实现代码 class a{ private $img_dir; private $img_path; private $face_files = array(); private $allow_extension = array(); private function...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn