- var_dump: documentation ( source)
- range: documentation ( source)
- join: documentation ( source)
<?php
$data = ['a' => ['b' => ['c' => 1]]];
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($data));
$flat = $keys = [];
foreach ($it as $node) {
foreach (range(0, $it->getDepth()) as $depth) {
$keys[] = $it->getSubIterator($depth)->key();
}
$flat[ join('.', $keys) ] = $node;
$keys = [];
}
var_dump($flat);