3v4l.org

run code in 300+ PHP versions simultaneously
<?php function skipFromBack(array $array, int $skip): array { $result = []; for ($index = array_key_last($array); $index > -1; $index -= 1 + $skip) { $result[] = $array[$index]; } return array_reverse($result); } $array = range(0, 15); foreach ([0, 1, 2, 3] as $skip) { var_export(skipFromBack($array, $skip)); echo "\n---\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/o0W0e
function name:  (null)
number of ops:  18
compiled vars:  !0 = $array, !1 = $skip
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 15
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
   13     5      > FE_RESET_R                                       $4      <array>, ->16
          6    > > FE_FETCH_R                                               $4, !1, ->16
   14     7    >   INIT_FCALL                                               'var_export'
          8        INIT_FCALL                                               'skipfromback'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        DO_FCALL                                      0  $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                                 
   15    14        ECHO                                                     '%0A---%0A'
   13    15      > JMP                                                      ->6
         16    >   FE_FREE                                                  $4
   16    17      > RETURN                                                   1

Function skipfromback:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 8
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 8
Branch analysis from position: 15
Branch analysis from position: 8
filename:       /in/o0W0e
function name:  skipFromBack
number of ops:  22
compiled vars:  !0 = $array, !1 = $skip, !2 = $result, !3 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, <array>
    5     3        INIT_FCALL                                               'array_key_last'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !3, $5
          7      > JMP                                                      ->13
    6     8    >   FETCH_DIM_R                                      ~8      !0, !3
          9        ASSIGN_DIM                                               !2
         10        OP_DATA                                                  ~8
    5    11        ADD                                              ~9      1, !1
         12        ASSIGN_OP                                     2          !3, ~9
         13    >   IS_SMALLER                                               -1, !3
         14      > JMPNZ                                                    ~11, ->8
    8    15    >   INIT_FCALL                                               'array_reverse'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $12     
         18        VERIFY_RETURN_TYPE                                       $12
         19      > RETURN                                                   $12
    9    20*       VERIFY_RETURN_TYPE                                       
         21*     > RETURN                                                   null

End of function skipfromback

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
531.95 ms | 1010 KiB | 18 Q