stat as $stat) { $name = getAgnosticField($stat, "Name"); if($stat["characterStat"] == "true") { processCharStat($mp, $stat); } else if (processStatName($name)) { $name = formatStat($stat, $name); fwrite($fh, $name."\n"); } } } foreach(scandir(".") as $file) { if(substr($file, -4) == ".xml") { $mp = substr($file, 0, 2) == "mp"; $stats = simplexml_load_file($file)->stats; if($stats->Category) { foreach($stats->Category as $category) { processStats($mp, $category); } } else { processStats($mp, $stats); } } } echo "Success.\n"; fwrite($fh, "};"); fclose($fh);