[PHP] - 로컬 폴더 하위 폴더 까지 찾기 ( 펌 )

PHP 2013. 1. 21. 15:35
반응형

function filesInDir ($tdir) 

if($dh = opendir ($tdir)) { 

$files = Array(); 

$in_files = Array(); 

while($a_file = readdir ($dh)) { 

if($a_file[0] != '.') { 

if(is_dir ($tdir . "/" . $a_file)) { 

$in_files = filesInDir ($tdir . "/" . $a_file); 

if(is_array ($in_files)) $files = array_merge ($files , $in_files); 

} else { 

array_push ($files , $tdir . "/" . $a_file); 

closedir ($dh); 

return $files ; 


foreach (filesInDir ('./1') as $key => $a_file){ 

echo ">>".$a_file . "<br>" ; 


출처 : http://tipsbox.tistory.com/entry/PHP-%EB%94%94%EB%A0%89%ED%86%A0%EB%A6%AC-%EB%82%B4%EC%9D%98-%ED%8C%8C%EC%9D%BC-%EB%AA%A9%EB%A1%9D-%ED%95%98%EC%9C%84-%EB%94%94%EB%A0%89%ED%86%A0%EB%A6%AC-%ED%8F%AC%ED%95%A8

반응형
: