Есть массив вида:
$array = [
'zzzzzz' => 'xxxxxxx',
'aaaaaa' => [
'sssssss' => [
'dddddd' => 'fffffff',
'ggggggg' => [
'uuuuuuu' => 'hhhhhhhhh'
],
'rrrrrrrr' => 'tttttttt'
],
'qqqqq' => 'aaaaa'
],
'wwwww' => 'ssssss'
];
Нужно привести его к следующему виду:
$out = [
'zzzzzz' => 'xxxxxxx',
'aaaaaa__sssssss__dddddd' => 'fffffff',
'aaaaaa__sssssss__ggggggg__uuuuuuu' => 'hhhhhhhhh',
'aaaaaa__sssssss__rrrrrrrr' => 'tttttttt',
'aaaaaa__qqqqqr' => 'aaaaa',
'wwwww' => 'ssssss',
];
Подскажите, как это можно сделать?