I am trying to get all XML files in my 10 subfolders and parse them. To do that I have the following code:
public static function calculateEAXML ($dir) {
$dh = opendir($dir);
$folderNames = array();
$arr = array();
while (false !== ($folderName = readdir($dh))) {
if ( $folderName[0] == "." || (substr($folderName, -3) == "zip") ) {continue;}
$folderNames[] = $folderName;
$dom = new DOMDocument;
$dom->validateOnParse = true;
foreach ($folderNames as $file)
{
if(is_dir($folderName)){ScanFiles::calculateEAXML($dir);}
else{
$df = opendir($dir . $file);
while (false !== ($file = readdir($df)))
{
if ($file == "." || $file == ".." ) {continue;}
$dom->Load($dir . $folderName . "/" . $file);
$arr[] = XML2Array::createArray($dom);
}
}
}
return $arr;
}
}
The thing is it parses the files only in ONE directory completely ignoring the other. Are there any ideas how to make it parse all the files in ALL directories?