3v4l.org

run code in 500+ PHP versions simultaneously
<?php $menu = [ 'root' => [ 'items' => [ 'A' => [ 'p' => [1, 2, 9], ], 'B' => [ 'p' => [1, 2, 3, 9], ], 'C' => [ 'p' => [1, 2, 4, 9], ], 'D' => [ 'items' => [ 'D1' => [ 'p' => [1, 2, 3, 4, 9], ], 'D2' => [ 'p' => [1, 2, 3, 4], ], ], ], 'E' => [ 'items' => [ 'E1' => [ 'p' => [1, 2, 10], ], ], ], 'F' => [ 'items' => [ 'F1' => [ 'p' => [5, 6], ], 'F2' => [ 'p' => [7, 8], ], ], ], ], ], ]; function recursive_ps($elem) { $output = []; if (isset($elem['items'])) { foreach($elem['items'] as $key => $value) { if (isset($value['p'])) { $output = array_merge($output, $value['p']); } if (isset($value['items'])) { // merge the return value of function $output = array_merge($output, recursive_ps($value)); } } } return $output; } $output = array_values(array_unique(recursive_ps($menu['root']))); print_r($output);
Output for rfc.property-hooks, git.master, git.master_jit
Array ( [0] => 1 [1] => 2 [2] => 9 [3] => 3 [4] => 4 [5] => 10 [6] => 5 [7] => 6 [8] => 7 [9] => 8 )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
40.5 ms | 1442 KiB | 4 Q