3v4l.org

run code in 300+ PHP versions simultaneously
<?php function weeks_in_month($month, $year) { $dates = []; $week = 1; $date = new DateTime("$year-$month-01"); $days = (int)$date->format('t'); // total number of days in the month $oneDay = new DateInterval('P1D'); for ($day = 1; $day <= $days; $day++) { $dates["Week $week"] []= $date->format('d/m/Y'); $dayOfWeek = $date->format('l'); if ($dayOfWeek === 'Saturday') { $week++; } $date->add($oneDay); } return $dates; } print_r(weeks_in_month(1, 2018));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IKGMG
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'weeks_in_month'
          2        SEND_VAL                                                 1
          3        SEND_VAL                                                 2018
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   28     7      > RETURN                                                   1

Function weeks_in_month:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 23
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 38
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 23
Branch analysis from position: 44
Branch analysis from position: 23
Branch analysis from position: 38
filename:       /in/IKGMG
function name:  weeks_in_month
number of ops:  46
compiled vars:  !0 = $month, !1 = $year, !2 = $dates, !3 = $week, !4 = $date, !5 = $days, !6 = $oneDay, !7 = $day, !8 = $dayOfWeek
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        ASSIGN                                                   !2, <array>
    7     3        ASSIGN                                                   !3, 1
    8     4        NEW                                              $11     'DateTime'
          5        ROPE_INIT                                     4  ~13     !1
          6        ROPE_ADD                                      1  ~13     ~13, '-'
          7        ROPE_ADD                                      2  ~13     ~13, !0
          8        ROPE_END                                      3  ~12     ~13, '-01'
          9        SEND_VAL_EX                                              ~12
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !4, $11
    9    12        INIT_METHOD_CALL                                         !4, 'format'
         13        SEND_VAL_EX                                              't'
         14        DO_FCALL                                      0  $17     
         15        CAST                                          4  ~18     $17
         16        ASSIGN                                                   !5, ~18
   11    17        NEW                                              $20     'DateInterval'
         18        SEND_VAL_EX                                              'P1D'
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !6, $20
   13    21        ASSIGN                                                   !7, 1
         22      > JMP                                                      ->42
   14    23    >   NOP                                                      
         24        FAST_CONCAT                                      ~24     'Week+', !3
         25        INIT_METHOD_CALL                                         !4, 'format'
         26        SEND_VAL_EX                                              'd%2Fm%2FY'
         27        DO_FCALL                                      0  $27     
         28        FETCH_DIM_W                                      $25     !2, ~24
         29        ASSIGN_DIM                                               $25
         30        OP_DATA                                                  $27
   16    31        INIT_METHOD_CALL                                         !4, 'format'
         32        SEND_VAL_EX                                              'l'
         33        DO_FCALL                                      0  $28     
         34        ASSIGN                                                   !8, $28
   17    35        IS_IDENTICAL                                             !8, 'Saturday'
         36      > JMPZ                                                     ~30, ->38
   18    37    >   PRE_INC                                                  !3
   21    38    >   INIT_METHOD_CALL                                         !4, 'add'
         39        SEND_VAR_EX                                              !6
         40        DO_FCALL                                      0          
   13    41        PRE_INC                                                  !7
         42    >   IS_SMALLER_OR_EQUAL                                      !7, !5
         43      > JMPNZ                                                    ~34, ->23
   24    44    > > RETURN                                                   !2
   25    45*     > RETURN                                                   null

End of function weeks_in_month

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.62 ms | 1009 KiB | 15 Q