Created
October 26, 2016 07:57
-
-
Save anonymous/f61c1b197cdba41dd8db9bfd25cd90ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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