3v4l.org

run code in 300+ PHP versions simultaneously
<?php $events = ['event 1', 'event 2', 'event 3']; $dayOfCycle = 12; function eventForDay($events, $dayOfCycle){ return $events[--$dayOfCycle % count($events)]; } echo eventForDay($events, $dayOfCycle); // should echo 'event 3' echo PHP_EOL; echo eventForDay($events, 8); // should echo 'event 2'
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9p1Ru
function name:  (null)
number of ops:  14
compiled vars:  !0 = $events, !1 = $dayOfCycle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, 12
   11     2        INIT_FCALL                                               'eventforday'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
   12     7        ECHO                                                     '%0A'
   13     8        INIT_FCALL                                               'eventforday'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 8
         11        DO_FCALL                                      0  $5      
         12        ECHO                                                     $5
         13      > RETURN                                                   1

Function eventforday:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9p1Ru
function name:  eventForDay
number of ops:  8
compiled vars:  !0 = $events, !1 = $dayOfCycle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        PRE_DEC                                          ~2      !1
          3        COUNT                                            ~3      !0
          4        MOD                                              ~4      ~2, ~3
          5        FETCH_DIM_R                                      ~5      !0, ~4
          6      > RETURN                                                   ~5
    9     7*     > RETURN                                                   null

End of function eventforday

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.95 ms | 998 KiB | 15 Q