首页 > php框架 > php 获取目录下所有文件实现代码

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

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

<?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;
    }
}


文章链接:http://www.phprm.com/frame/php1005192.html

随便收藏,请保留本文地址!

标签:none

发表留言