3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @param int $dayNum * @param array $daysArray */ function getNumberOfDays($dayNum, array $daysArray) { $dayNum ++; $size = count($daysArray); for ($x = 0; $x < $size; $x ++) { if ($daysArray[$x] == $dayNum && $x + 1 == $size) { $nextDay = $daysArray[0]; $totalDays = $dayOfWeek + $nextDay; return $totalDays % 7; } elseif ($daysArray[$x] == $dayNum) { return $daysArray[$x +1] - $dayNum; } elseif ($daysArray[$x] > $dayNum) { return $daysArray[$x] - $dayNum; } } } $dayOfWeek = date("w"); $array = array( 2,3,4,6 ); var_dump(date("w")); echo getNumberOfDays($dayOfWeek, $array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4V1U8
function name:  (null)
number of ops:  17
compiled vars:  !0 = $dayOfWeek, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'date'
          1        SEND_VAL                                                 'w'
          2        DO_ICALL                                         $2      
          3        ASSIGN                                                   !0, $2
   24     4        ASSIGN                                                   !1, <array>
   26     5        INIT_FCALL                                               'var_dump'
          6        INIT_FCALL                                               'date'
          7        SEND_VAL                                                 'w'
          8        DO_ICALL                                         $5      
          9        SEND_VAR                                                 $5
         10        DO_ICALL                                                 
   27    11        INIT_FCALL                                               'getnumberofdays'
         12        SEND_VAR                                                 !0
         13        SEND_VAR                                                 !1
         14        DO_FCALL                                      0  $7      
         15        ECHO                                                     $7
         16      > RETURN                                                   1

Function getnumberofdays:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 7
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 35
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 7
Branch analysis from position: 38
Branch analysis from position: 7
Branch analysis from position: 13
filename:       /in/4V1U8
function name:  getNumberOfDays
number of ops:  39
compiled vars:  !0 = $dayNum, !1 = $daysArray, !2 = $size, !3 = $x, !4 = $nextDay, !5 = $totalDays, !6 = $dayOfWeek
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        PRE_INC                                                  !0
    9     3        COUNT                                            ~8      !1
          4        ASSIGN                                                   !2, ~8
   10     5        ASSIGN                                                   !3, 0
          6      > JMP                                                      ->36
   11     7    >   FETCH_DIM_R                                      ~11     !1, !3
          8        IS_EQUAL                                         ~12     !0, ~11
          9      > JMPZ_EX                                          ~12     ~12, ->13
         10    >   ADD                                              ~13     !3, 1
         11        IS_EQUAL                                         ~14     !2, ~13
         12        BOOL                                             ~12     ~14
         13    > > JMPZ                                                     ~12, ->21
   12    14    >   FETCH_DIM_R                                      ~15     !1, 0
         15        ASSIGN                                                   !4, ~15
   13    16        ADD                                              ~17     !6, !4
         17        ASSIGN                                                   !5, ~17
   14    18        MOD                                              ~19     !5, 7
         19      > RETURN                                                   ~19
         20*       JMP                                                      ->35
   15    21    >   FETCH_DIM_R                                      ~20     !1, !3
         22        IS_EQUAL                                                 !0, ~20
         23      > JMPZ                                                     ~21, ->29
   16    24    >   ADD                                              ~22     !3, 1
         25        FETCH_DIM_R                                      ~23     !1, ~22
         26        SUB                                              ~24     ~23, !0
         27      > RETURN                                                   ~24
         28*       JMP                                                      ->35
   17    29    >   FETCH_DIM_R                                      ~25     !1, !3
         30        IS_SMALLER                                               !0, ~25
         31      > JMPZ                                                     ~26, ->35
   18    32    >   FETCH_DIM_R                                      ~27     !1, !3
         33        SUB                                              ~28     ~27, !0
         34      > RETURN                                                   ~28
   10    35    >   PRE_INC                                                  !3
         36    >   IS_SMALLER                                               !3, !2
         37      > JMPNZ                                                    ~30, ->7
   21    38    > > RETURN                                                   null

End of function getnumberofdays

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.52 ms | 1403 KiB | 18 Q