How can I convert an array to a SimpleXML object in PHP?
I found this solution similar to the original problem
'blub',
'foo' => 'bar',
'another_array' => array (
'stack' => 'overflow',
),
);
class NoSimpleXMLElement extends SimpleXMLElement {
public function addChild($name,$value) {
parent::addChild($value,$name);
}
}
$xml = new NoSimpleXMLElement(' ');
array_walk_recursive($test_array, array ($xml, 'addChild'));
print $xml->asXML();