continue;
} $stack =
[&
$pointer];
$iterator =
new RecursiveIteratorIterator( new RecursiveArrayIterator($value),
RecursiveIteratorIterator::SELF_FIRST
);
foreach ($iterator as $key =>
$val) { array_splice($stack,
$iterator->
getDepth() + 1
);
$pointer = &
$stack[count($stack) - 1
];
$pointer = &
$pointer[$key];
$stack[] = &
$pointer;
// RecursiveIteratorIterator::hasChildren() can be used. RecursiveIteratorIterator
// forwards all unknown method calls to the underlying RecursiveIterator internally.
// See https://github.com/php/doc-en/issues/787#issuecomment-881446121
if (!
$iterator->
hasChildren()) { $pointer[$field] =
$val;
} } }