디렉토리에서 사용 가능한 모든 서브 디렉토리를 가져와 그 디렉토리의 이름을 저장해야하며, XML 파일을 포함하는 경우 해당 파일에 대해 작업해야합니다.PHP : 디렉토리의 모든 하위 디렉토리를 찾습니다. 그들이 유효한 XML 파일을 가지고 있다면 그것으로 작업하십시오.
여기에 약간의 코드와 내가 작성한 의견이 있습니다.
<?php
$path = "http://source.com/path/to/subs/";
//Check for any subdirectories
foreach($subdirectory as $sub){
$name = //subdirectory's name;
// Filepath is always http://source.com/path/to/subs/name_of_sub/description.xml
$file = $path . $name . 'description.xml';
if(file_exists($file)){
//do my stuff here
}
}
//end check
?>
많은 PHP 기능 : opendir, readdir, glob, scandir .. –