function convert_simplexml_to_array($sxml) { if ($sxml) { foreach ($sxml as $k => $v) { var_dump($k, (string) $v); convert_simplexml_to_array($v); } } }
function convert_simplexml_to_array($sxml) { $arr = array(); if ($sxml) { foreach ($sxml as $k => $v) { if ($sxml['list']) { if (isset($v['key'])) { $arr[(string) $v['key']] = convert_simplexml_to_array($v); } else { $arr[] = convert_simplexml_to_array($v); } } else { $arr[$k] = convert_simplexml_to_array($v); } } } if (sizeof($arr) > 0) { return $arr; } else { return (string) $sxml; } }