3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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);
based on DOpad
Output for 7.0.0 - 7.2.0
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.
Output for 5.4.2 - 5.6.28
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: Call to undefined function array_keys_recursive() in /in/u2JPj on line 27
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/u2JPj on line 4
Process exited with code 255.