3v4l.org

run code in 300+ PHP versions simultaneously
<?php $list = range(2, 5); $listLength = count($list); foreach (range(-1000000, -1000000 + 10) as $i) { $key = ($i + 2) % $listLength; if ($key < 0) { $key = $listLength + ($key % $listLength); } echo $list[$key]; echo PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 25
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 25
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 21
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/S6ZId
function name:  (null)
number of ops:  27
compiled vars:  !0 = $list, !1 = $listLength, !2 = $i, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 2
          2        SEND_VAL                                                 5
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !0, $4
    4     5        COUNT                                            ~6      !0
          6        ASSIGN                                                   !1, ~6
    6     7        INIT_FCALL                                               'range'
          8        SEND_VAL                                                 -1000000
          9        SEND_VAL                                                 -999990
         10        DO_ICALL                                         $8      
         11      > FE_RESET_R                                       $9      $8, ->25
         12    > > FE_FETCH_R                                               $9, !2, ->25
    7    13    >   ADD                                              ~10     !2, 2
         14        MOD                                              ~11     ~10, !1
         15        ASSIGN                                                   !3, ~11
    9    16        IS_SMALLER                                               !3, 0
         17      > JMPZ                                                     ~13, ->21
   10    18    >   MOD                                              ~14     !3, !1
         19        ADD                                              ~15     !1, ~14
         20        ASSIGN                                                   !3, ~15
   13    21    >   FETCH_DIM_R                                      ~17     !0, !3
         22        ECHO                                                     ~17
   14    23        ECHO                                                     '%0A'
    6    24      > JMP                                                      ->12
         25    >   FE_FREE                                                  $9
   15    26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.57 ms | 1396 KiB | 15 Q