3v4l.org

run code in 500+ 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 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 19
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 19
Branch analysis from position: 39
Branch analysis from position: 19
filename:       /in/1QmX5
function name:  (null)
number of ops:  40
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                                                          ->37
   11    19    >   FRAMELESS_ICALL_2                max                 ~15     !0, !2
         20        INIT_METHOD_CALL                                             ~15, 'format'
         21        SEND_VAL_EX                                                  'Y-m-d'
         22        DO_FCALL                                          0  $16     
         23        CONCAT                                               ~17     $16, '+to+'
         24        INIT_METHOD_CALL                                             !2, 'modify'
         25        SEND_VAL_EX                                                  '%2B6+days'
         26        DO_FCALL                                          0  $18     
         27        FRAMELESS_ICALL_2                min                 ~19     $18, !1
         28        INIT_METHOD_CALL                                             ~19, 'format'
         29        SEND_VAL_EX                                                  'Y-m-d'
         30        DO_FCALL                                          0  $20     
         31        CONCAT                                               ~21     ~17, $20
         32        CONCAT                                               ~22     ~21, '%0A'
         33        ECHO                                                         ~22
   12    34        INIT_METHOD_CALL                                             !2, 'modify'
         35        SEND_VAL_EX                                                  '%2B1+day'
         36        DO_FCALL                                          0          
   10    37    >   IS_SMALLER_OR_EQUAL                                          !2, !1
         38      > JMPNZ                                                        ~24, ->19
   13    39    > > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.67 ms | 2163 KiB | 13 Q