3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'name' => 'a', 'url' => 'b', ], [ 'no-name' => 'foo', ], [ 'name' => 'c', 'url' => 'd', 'children' => [ [ 'name' => 'e', 'url' => 'f' ] ] ] ]; function recurseAll(&$node) { if (is_array($node)) { if (isset($node['name'])) { // do something with the qualifying array... $node[] = 'push a new element into array level'; } foreach ($node as &$childNode) { recurseAll($childNode); } } } recurseAll($array); var_export($array);

preferences:
31.48 ms | 404 KiB | 5 Q