3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'a' => [ 'b1' => [ 'c1' => [ 'e1' => 4, 'f1' => 5, 'g1' => 6, ], 'd1' => [ 'e11' => 4, 'f11' => 5, 'g11' => 6, ] ], 'b2' => [ 'c2' => [ 'e2' => 4, 'f2' => 5, 'g2' => 6, ], 'd2' => [ 'e21' => 4, 'f21' => 5, 'g21' => 6, ] ], ] ]; function reverse_recursively($arrayInput) { foreach ($arrayInput as $key => $input) { if (is_array($input)) { $arrayInput[$key] = reverse_recursively($input); } } return array_reverse($arrayInput); } echo '<pre>'; print_r($array); echo '<br>'; print_r(reverse_recursively($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2pYhR
function name:  (null)
number of ops:  13
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   42     1        ECHO                                                     '%3Cpre%3E'
   43     2        INIT_FCALL                                               'print_r'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   44     5        ECHO                                                     '%3Cbr%3E'
   45     6        INIT_FCALL                                               'print_r'
          7        INIT_FCALL                                               'reverse_recursively'
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0  $3      
         10        SEND_VAR                                                 $3
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function reverse_recursively:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/2pYhR
function name:  reverse_recursively
number of ops:  18
compiled vars:  !0 = $arrayInput, !1 = $input, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
   33     1      > FE_RESET_R                                       $3      !0, ->12
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->12
          3    >   ASSIGN                                                   !2, ~4
   34     4        TYPE_CHECK                                  128          !1
          5      > JMPZ                                                     ~6, ->11
   35     6    >   INIT_FCALL_BY_NAME                                       'reverse_recursively'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $8      
          9        ASSIGN_DIM                                               !0, !2
         10        OP_DATA                                                  $8
   33    11    > > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   39    13        INIT_FCALL                                               'array_reverse'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $9      
         16      > RETURN                                                   $9
   40    17*     > RETURN                                                   null

End of function reverse_recursively

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.69 ms | 1009 KiB | 16 Q