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);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u2JPj
function name:  (null)
number of ops:  37
compiled vars:  !0 = $arr, !1 = $a, !2 = $b, !3 = $c, !4 = $d, !5 = $e, !6 = $f, !7 = $g, !8 = $keys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    6     3        ASSIGN                                                   !3, <array>
    7     4        ASSIGN                                                   !4, <array>
    8     5        ASSIGN                                                   !5, <array>
    9     6        ASSIGN                                                   !6, <array>
   10     7        ASSIGN                                                   !7, <array>
   11     8        ASSIGN_DIM                                               !0
          9        OP_DATA                                                  !1
   12    10        ASSIGN_DIM                                               !0
         11        OP_DATA                                                  !2
   13    12        ASSIGN_DIM                                               !0
         13        OP_DATA                                                  !3
   14    14        FETCH_DIM_W                                      $20     !0, 0
         15        ASSIGN_DIM                                               $20, 2
         16        OP_DATA                                                  !4
   15    17        FETCH_DIM_W                                      $22     !0, 0
         18        FETCH_DIM_W                                      $23     $22, 2
         19        ASSIGN_DIM                                               $23, 3
         20        OP_DATA                                                  !5
   16    21        FETCH_DIM_W                                      $25     !0, 2
         22        ASSIGN_DIM                                               $25, 1
         23        OP_DATA                                                  !6
   17    24        ASSIGN_DIM                                               !0, 1
         25        OP_DATA                                                  !7
   19    26        INIT_FCALL                                               'print_r'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                                 
   35    29        INIT_FCALL                                               'array_keys_recur'
         30        SEND_VAR                                                 !0
         31        DO_FCALL                                      0  $29     
         32        ASSIGN                                                   !8, $29
   37    33        INIT_FCALL                                               'print_r'
         34        SEND_VAR                                                 !8
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Function array_keys_recur:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 27
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 26
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 26
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 25
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 25
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 27
filename:       /in/u2JPj
function name:  array_keys_recur
number of ops:  29
compiled vars:  !0 = $myArray, !1 = $MAXDEPTH, !2 = $depth, !3 = $arrayKeys, !4 = $keys, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <const ast>
          2        RECV_INIT                                        !2      0
          3        RECV_INIT                                        !3      <array>
   22     4        IS_SMALLER                                               !2, !1
          5      > JMPZ                                                     ~6, ->27
   23     6    >   PRE_INC                                                  !2
   24     7        INIT_FCALL                                               'array_keys'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !4, $8
   25    11      > FE_RESET_R                                       $10     !4, ->26
         12    > > FE_FETCH_R                                               $10, !5, ->26
   26    13    >   FETCH_DIM_R                                      ~11     !0, !5
         14        TYPE_CHECK                                  128          ~11
         15      > JMPZ                                                     ~12, ->25
   27    16    >   INIT_FCALL_BY_NAME                                       'array_keys_recursive'
         17        CHECK_FUNC_ARG                                           
         18        FETCH_DIM_FUNC_ARG                               $14     !0, !5
         19        SEND_FUNC_ARG                                            $14
         20        SEND_VAR_EX                                              !1
         21        SEND_VAR_EX                                              !2
         22        DO_FCALL                                      0  $15     
         23        ASSIGN_DIM                                               !3, !5
         24        OP_DATA                                                  $15
   25    25    > > JMP                                                      ->12
         26    >   FE_FREE                                                  $10
   32    27    > > RETURN                                                   !3
   33    28*     > RETURN                                                   null

End of function array_keys_recur

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.75 ms | 1403 KiB | 18 Q