multimap($arr);
function multimap($array, $level = 0) {
$result = [];
foreach ($array as $key => $data) {
foreach ($data as $inner) {
$result[$key] = [
'id' => $inner['@attributes']['id'],
'name' => $inner['@attributes']['name']
];
if ($level == 0) {
$result[$key]['parent'] = $inner['@attributes']['parent'];
}
unset($inner['@attributes']);
$result = \array_merge($result, multimap($inner, $level+1));
}
}
return $result;
}