GreensnoWorld
记录点滴,分享乐趣,一块凝固的时间
glob() 函数遍历查找
PHP  2017年3月4日
<?php
    function findFile($pathName, $exts=''){
        if(!empty($exts)){
            for($i=0,$limit=count($exts); $i<$limit; $i++){
                $exts[$i] = "*.".$exts[$i];
            }
            $filter = (!$exts)?"*":"{".implode(",",$exts)."}";
            $pattern = $pathName."/".$filter;
            return glob($pattern, GLOB_BRACE);
        }
    }
    
    $arr = findFile($pathName, array(ext1, ext2));
    print_r($arr);
?>
LIJG
余本顽劣,生于紫云下,长于汝水滨。早年求学,兴趣广泛,好高骛远,学无所成,仓皇入世。兴趣所致,投身互联网,求知未证,而立已至,始悟光阴荏苒,终需务实钻研。故有此站,记录时光,积累点滴,验证所学,分享愚见。指舞方寸间,心系万千年。
留言