3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array(); $a = [0,1,2,3,4,5]; $b = [0,1,2,3,4,5]; $c = [0,1,2,3,4,5]; $d = [0,1,2,3,4,5]; $e = [0,1,2,3,4,5]; $f = [0,1,2,3,4,5]; $g = [0,1,2,3,4,5]; $arr[] = $a; $arr[] = $b; $arr[] = $c; $arr[0][2] = $d; $arr[0][2][3] = $e; $arr[2][1] = $f; $arr[1] = $g; print_r($arr); function array_keys_recur($myArray, $MAXDEPTH = INF, $depth = 0, $arrayKeys = array()){ if($depth < $MAXDEPTH){ $depth++; $keys = array_keys($myArray); foreach($keys as $key){ if(is_array($myArray[$key])){ $arrayKeys[$key] = array_keys_recursive($myArray[$key], $MAXDEPTH, $depth); } } } return $arrayKeys; } $keys = array_keys_recur($arr); print_r($keys);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [0] => 0 [1] => 1 [2] => Array ( [0] => 0 [1] => 1 [2] => 2 [3] => Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 ) [4] => 4 [5] => 5 ) [3] => 3 [4] => 4 [5] => 5 ) [1] => Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 ) [2] => Array ( [0] => 0 [1] => Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 ) [2] => 2 [3] => 3 [4] => 4 [5] => 5 ) ) Fatal error: Uncaught Error: Call to undefined function array_keys_recursive() in /in/u2JPj:27 Stack trace: #0 /in/u2JPj(35): array_keys_recur(Array) #1 {main} thrown in /in/u2JPj on line 27
Process exited with code 255.

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:
43.58 ms | 403 KiB | 8 Q