3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = [1,2,3,4,5]; function array_rotate(&$array, $step = 1) { $length = count($array); end($array); while ($step--) prev($array); while ($length--) { next($array); if (key($array) === null) reset($array); yield current($array); } } print_r(iterator_to_array(array_rotate($a, 2)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dZX69
function name:  (null)
number of ops:  12
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   22     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'iterator_to_array'
          3        INIT_FCALL                                               'array_rotate'
          4        SEND_REF                                                 !0
          5        SEND_VAL                                                 2
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                         $3      
          9        SEND_VAR                                                 $3
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function array_rotate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 9
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 15
Branch analysis from position: 32
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 26
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 15
Branch analysis from position: 32
Branch analysis from position: 15
Branch analysis from position: 26
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 9
Branch analysis from position: 14
Branch analysis from position: 9
filename:       /in/dZX69
function name:  array_rotate
number of ops:  33
compiled vars:  !0 = $array, !1 = $step, !2 = $length
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      1
          2        GENERATOR_CREATE                                         
    6     3        COUNT                                            ~3      !0
          4        ASSIGN                                                   !2, ~3
    8     5        INIT_FCALL                                               'end'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                                 
   10     8      > JMP                                                      ->12
   11     9    >   INIT_FCALL                                               'prev'
         10        SEND_REF                                                 !0
         11        DO_ICALL                                                 
   10    12    >   POST_DEC                                         ~7      !1
         13      > JMPNZ                                                    ~7, ->9
   13    14    > > JMP                                                      ->30
   14    15    >   INIT_FCALL                                               'next'
         16        SEND_REF                                                 !0
         17        DO_ICALL                                                 
   15    18        INIT_FCALL                                               'key'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $9      
         21        TYPE_CHECK                                    2          $9
         22      > JMPZ                                                     ~10, ->26
   16    23    >   INIT_FCALL                                               'reset'
         24        SEND_REF                                                 !0
         25        DO_ICALL                                                 
   18    26    >   INIT_FCALL                                               'current'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $12     
         29        YIELD                                                    $12
   13    30    >   POST_DEC                                         ~14     !2
         31      > JMPNZ                                                    ~14, ->15
   20    32    > > GENERATOR_RETURN                                         

End of function array_rotate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.17 ms | 967 KiB | 22 Q