//再起的にファイルのパスを取得
function lfGetFilePathRecursive($parentPath, $rootPath=NULL, $image_only=false){
$arrResult = array();
$parentPath = preg_replace('/\/$/', '', $parentPath);
$rootPath = preg_replace('/\/$/', '', $rootPath);
if(is_dir($rootPath.$parentPath)){
$arrChilds = scandir($rootPath.$parentPath);
foreach($arrChilds as $child){
if(preg_match('/^[^.].+/', $child)){
$childPath = $parentPath.'/'.$child;
if(is_dir($rootPath.$childPath)){
$arrResult = array_merge($arrResult, $this->lfGetFilePathRecursive($childPath, $rootPath, $image_only));
}else{
if($image_only){
switch(exif_imagetype($rootPath.$childPath)){
case IMAGETYPE_GIF:
case IMAGETYPE_JPEG:
case IMAGETYPE_PNG:
case IMAGETYPE_BMP:
break;
default:
continue 2;
}
}
$arrResult[] = $childPath;
}
}
}
}
return $arrResult;
}
再起的にファイルのパスを取得
投稿者:
タグ: