All I want is to convert a super-simple SimpleXML object to an array. “super-simple” means no attributes, etc. Nothing that is XML-specific.
$xml_string = "
<sub_first_thing_a>Hi, I am the content of the first thing.</sub_first_thing_a>
<sub_first_thing_b>Hi, more content.</sub_first_thing_b>
<second_thing>Notice, no attributes or anything fancy.</second_thing>
$simplexml_object = simplexml_load_string($xml_string);
Why? Because a number of functions, libraries, etc. return SimpleXML objects. For example, the 1.x version of the very-awesome AWS PHP SDK tends to return SimpleXML objects. And 9 times out of 10 all I need is a multi-dimensional, usually keyed (associative) array. (more…)