Created
April 25, 2012 16:03
-
-
Save damiankloip/2490938 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
function xml_to_array(SimpleXMLIterator $xml) { | |
$out = array(); | |
foreach ($xml as $key => $value) { | |
if ($xml->hasChildren()) { | |
$out[$key] = xml_to_array($value); | |
} | |
else { | |
if ($attributes = (array) $value->attributes()) { | |
$out['#attributes'] = $attributes['@attributes']; | |
} | |
$out[$key] = (string) $value; | |
} | |
} | |
return $out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment