3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Input date format: YYYY-mm-dd function getMonthWeekNumbers( $first_date ) { $last_date = date( "Y-m-t",strtotime( $first_date ) ); $first_week = date( "W",strtotime( $first_date ) ); $last_week = date( "W",strtotime( $last_date ) ); // If last day of month have on first week on next year, subtract a week from the date if( $last_week == '01' ) { $last_week = date( "W",( strtotime( $last_date )-604800 ) ); } for( $i=$first_week; $i <= $last_week; $i++ ) { echo "Week #".$i.", "; } } getMonthWeekNumbers( '2019-12-01' );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hSemf
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'getmonthweeknumbers'
          1        SEND_VAL                                                 '2019-12-01'
          2        DO_FCALL                                      0          
          3      > RETURN                                                   1

Function getmonthweeknumbers:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 36
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 38
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 38
Branch analysis from position: 44
Branch analysis from position: 38
Branch analysis from position: 36
filename:       /in/hSemf
function name:  getMonthWeekNumbers
number of ops:  45
compiled vars:  !0 = $first_date, !1 = $last_date, !2 = $first_week, !3 = $last_week, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'date'
          2        SEND_VAL                                                 'Y-m-t'
          3        INIT_FCALL                                               'strtotime'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6        SEND_VAR                                                 $5
          7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !1, $6
    7     9        INIT_FCALL                                               'date'
         10        SEND_VAL                                                 'W'
         11        INIT_FCALL                                               'strtotime'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $8      
         14        SEND_VAR                                                 $8
         15        DO_ICALL                                         $9      
         16        ASSIGN                                                   !2, $9
    8    17        INIT_FCALL                                               'date'
         18        SEND_VAL                                                 'W'
         19        INIT_FCALL                                               'strtotime'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $11     
         22        SEND_VAR                                                 $11
         23        DO_ICALL                                         $12     
         24        ASSIGN                                                   !3, $12
   11    25        IS_EQUAL                                                 !3, '01'
         26      > JMPZ                                                     ~14, ->36
   13    27    >   INIT_FCALL                                               'date'
         28        SEND_VAL                                                 'W'
         29        INIT_FCALL                                               'strtotime'
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                         $15     
         32        SUB                                              ~16     $15, 604800
         33        SEND_VAL                                                 ~16
         34        DO_ICALL                                         $17     
         35        ASSIGN                                                   !3, $17
   16    36    >   ASSIGN                                                   !4, !2
         37      > JMP                                                      ->42
   18    38    >   CONCAT                                           ~20     'Week+%23', !4
         39        CONCAT                                           ~21     ~20, '%2C+'
         40        ECHO                                                     ~21
   16    41        PRE_INC                                                  !4
         42    >   IS_SMALLER_OR_EQUAL                                      !4, !3
         43      > JMPNZ                                                    ~23, ->38
   20    44    > > RETURN                                                   null

End of function getmonthweeknumbers

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.72 ms | 1006 KiB | 16 Q