3v4l.org

run code in 500+ PHP versions simultaneously
<?php function recursiveArrayReverse($a) { $size = count($a); if ($size < 2) { return $a; } return array_merge( [$a[$size - 1]], recursiveArrayReverse( array_slice($a, 1, -1) ), [$a[0]] ); } $array = [1, 2, 3, 4, 5, 6, 7]; $array = recursiveArrayReverse($array); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lK4DZ
function name:  (null)
number of ops:  9
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                       !0, <array>
   18     1        INIT_FCALL                                                   'recursivearrayreverse'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $2      
          4        ASSIGN                                                       !0, $2
   19     5        INIT_FCALL                                                   'var_export'
          6        SEND_VAR                                                     !0
          7        DO_ICALL                                                     
          8      > RETURN                                                       1

Function recursivearrayreverse:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lK4DZ
function name:  recursiveArrayReverse
number of ops:  26
compiled vars:  !0 = $a, !1 = $size
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        COUNT                                                ~2      !0
          2        ASSIGN                                                       !1, ~2
    5     3        IS_SMALLER                                                   !1, 2
          4      > JMPZ                                                         ~4, ->6
    6     5    > > RETURN                                                       !0
    8     6    >   INIT_FCALL                                                   'array_merge'
    9     7        SUB                                                  ~5      !1, 1
          8        FETCH_DIM_R                                          ~6      !0, ~5
          9        INIT_ARRAY                                           ~7      ~6
         10        SEND_VAL                                                     ~7
   10    11        INIT_FCALL_BY_NAME                                           'recursiveArrayReverse'
   11    12        INIT_FCALL                                                   'array_slice'
         13        SEND_VAR                                                     !0
         14        SEND_VAL                                                     1
         15        SEND_VAL                                                     -1
         16        DO_ICALL                                             $8      
         17        SEND_VAR_NO_REF_EX                                           $8
   10    18        DO_FCALL                                          0  $9      
   11    19        SEND_VAR                                                     $9
   13    20        FETCH_DIM_R                                          ~10     !0, 0
         21        INIT_ARRAY                                           ~11     ~10
         22        SEND_VAL                                                     ~11
    8    23        DO_ICALL                                             $12     
   13    24      > RETURN                                                       $12
   15    25*     > RETURN                                                       null

End of function recursivearrayreverse

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.12 ms | 2106 KiB | 17 Q