3v4l.org

run code in 300+ PHP versions simultaneously
<?php $month_start = new DateTime("first day of this month"); $month_end = new DateTime("last day of this month"); // find the monday on/before the start of the month $start_date = clone $month_start; $start_date->modify((1 - $start_date->format('N')) . ' days'); while ($start_date <= $month_end) { echo max($month_start, $start_date)->format('Y-m-d') . ' to ' . min($start_date->modify('+6 days'), $month_end)->format('Y-m-d') . "\n"; $start_date->modify('+1 day'); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 19
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 19
Branch analysis from position: 45
Branch analysis from position: 19
filename:       /in/1QmX5
function name:  (null)
number of ops:  46
compiled vars:  !0 = $month_start, !1 = $month_end, !2 = $start_date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $3      'DateTime'
          1        SEND_VAL_EX                                              'first+day+of+this+month'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
    4     4        NEW                                              $6      'DateTime'
          5        SEND_VAL_EX                                              'last+day+of+this+month'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $6
    7     8        CLONE                                            ~9      !0
          9        ASSIGN                                                   !2, ~9
    8    10        INIT_METHOD_CALL                                         !2, 'modify'
         11        INIT_METHOD_CALL                                         !2, 'format'
         12        SEND_VAL_EX                                              'N'
         13        DO_FCALL                                      0  $11     
         14        SUB                                              ~12     1, $11
         15        CONCAT                                           ~13     ~12, '+days'
         16        SEND_VAL_EX                                              ~13
         17        DO_FCALL                                      0          
   10    18      > JMP                                                      ->43
   11    19    >   INIT_FCALL                                               'max'
         20        SEND_VAR                                                 !0
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                         $15     
         23        INIT_METHOD_CALL                                         $15, 'format'
         24        SEND_VAL_EX                                              'Y-m-d'
         25        DO_FCALL                                      0  $16     
         26        CONCAT                                           ~17     $16, '+to+'
         27        INIT_FCALL                                               'min'
         28        INIT_METHOD_CALL                                         !2, 'modify'
         29        SEND_VAL_EX                                              '%2B6+days'
         30        DO_FCALL                                      0  $18     
         31        SEND_VAR                                                 $18
         32        SEND_VAR                                                 !1
         33        DO_ICALL                                         $19     
         34        INIT_METHOD_CALL                                         $19, 'format'
         35        SEND_VAL_EX                                              'Y-m-d'
         36        DO_FCALL                                      0  $20     
         37        CONCAT                                           ~21     ~17, $20
         38        CONCAT                                           ~22     ~21, '%0A'
         39        ECHO                                                     ~22
   12    40        INIT_METHOD_CALL                                         !2, 'modify'
         41        SEND_VAL_EX                                              '%2B1+day'
         42        DO_FCALL                                      0          
   10    43    >   IS_SMALLER_OR_EQUAL                                      !2, !1
         44      > JMPNZ                                                    ~24, ->19
   13    45    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.19 ms | 1405 KiB | 17 Q