I am trying to convert xml into associative array.
foreach($xml->children() as $child)
{
$ages[$child->getName()] = $child;
}
But when I print out this array ‘ages’, I am getting output as
[Quagmire] => SimpleXMLElement Object
(
[0] => 30
)
instead of
[Quagmire] => 30
What change do I make to get the desired output?
You can explicitly cast the value of the child from a SimpleXML object to an int.