Convert SimpleXMLElement to Array

Ok, I know this is simple, but it took me a while to realize this simple method to convert SimpleXMLElement to an array. (I even tempted to write a function to parse and convert the XML tree).

Its simple actually, to just just the default PHP functions

$xml = <tag>content</tag>
print_r(json_decode(json_encode($xml), TRUE));

Comments

Popular posts from this blog

[Azure Websites PHP] Cross Domain request results in blank response page after Preflight HTTP OPTIONS

[Magento] Create Contact Form with Dynamic Recipient