Skip to content

Instantly share code, notes, and snippets.

@mrprompt
Created June 7, 2013 03:35
Show Gist options
  • Save mrprompt/5726919 to your computer and use it in GitHub Desktop.
Save mrprompt/5726919 to your computer and use it in GitHub Desktop.
Array para XML
<?php
/**
* Transforma um array em xml
*/
$test_array = array (
'bla' => 'blub',
'foo' => 'bar',
'another_array' => array (
'stack' => 'overflow',
),
);
$xml = new SimpleXMLElement('<root/>');
array_walk_recursive($test_array, array ($xml, 'addChild'));
print $xml->asXML();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment