'bar', 'baz' => 'burp', 'something_a_bit_longer' => 1, 'hubba' => 'bubba', 'bubba' => 'hubba', 'yah' => 'boo', 'banana' => 0, ); $n = 0; while ($n < 500) { $n++; $xml = '' ."\n" . assocToXML($config) . "\n"; file_put_contents(DRUPAL_ROOT . '/' . $dir . "/$n.xml", $xml); } function assocToXML($theArray, $tabCount=0) { // parse the array for data and output xml foreach($theArray as $tag => $val) { if (!is_array($val)) { $theXML .= PHP_EOL.'<'.$tag.'>'.htmlentities($val).''; } else { $tabCount++; $theXML .= PHP_EOL.'<'.$tag.'>'.assocToXML($val, $tabCount); $theXML .= PHP_EOL.''; } } return $theXML; }