Skip to content

Instantly share code, notes, and snippets.

Created October 26, 2016 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/f61c1b197cdba41dd8db9bfd25cd90ab to your computer and use it in GitHub Desktop.
Save anonymous/f61c1b197cdba41dd8db9bfd25cd90ab to your computer and use it in GitHub Desktop.
<?php
function array2xml($array, $xml = false){
if($xml === false){
$xml = new SimpleXMLElement('<result/>');
}
foreach($array as $key => $value){
if(is_array($value)){
array2xml($value, $xml->addChild($key));
} else {
$xml->addChild($key, $value);
}
}
$xml->asXML("members.xml");
return $xml->asXML();
}
$raw_data = file_get_contents('http://pastebin.com/raw.php?i=pN3QwSHU');
$jSON = json_decode($raw_data, true);
$xml = array2xml($jSON, false);
echo '<pre>';
print_r($xml);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment