3v4l.org

run code in 300+ PHP versions simultaneously
<?php $year = date_create('today')->format('Y'); //remove comment next line for test's //$year = 2001; $dtStart = date_create('2 jan '.$year)->modify('last Monday'); $dtEnd = date_create('last monday of Dec '.$year); for($weeks = [];$dtStart <= $dtEnd;$dtStart->modify('+1 week')){ $key = $dtStart->format('W-Y'); $from = $dtStart->format('d/m/Y'); $to = (clone $dtStart)->modify('+6 Days')->format('d/m/Y'); $weeks[$key] = $from.' - '.$to; } var_export($weeks);

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 22
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 22
Branch analysis from position: 47
Branch analysis from position: 22
filename:       /in/2vK30
function name:  (null)
number of ops:  51
compiled vars:  !0 = $year, !1 = $dtStart, !2 = $dtEnd, !3 = $weeks, !4 = $key, !5 = $from, !6 = $to
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'date_create'
          1        SEND_VAL                                                 'today'
          2        DO_ICALL                                         $7      
          3        INIT_METHOD_CALL                                         $7, 'format'
          4        SEND_VAL_EX                                              'Y'
          5        DO_FCALL                                      0  $8      
          6        ASSIGN                                                   !0, $8
    6     7        INIT_FCALL                                               'date_create'
          8        CONCAT                                           ~10     '2+jan+', !0
          9        SEND_VAL                                                 ~10
         10        DO_ICALL                                         $11     
         11        INIT_METHOD_CALL                                         $11, 'modify'
         12        SEND_VAL_EX                                              'last+Monday'
         13        DO_FCALL                                      0  $12     
         14        ASSIGN                                                   !1, $12
    7    15        INIT_FCALL                                               'date_create'
         16        CONCAT                                           ~14     'last+monday+of+Dec+', !0
         17        SEND_VAL                                                 ~14
         18        DO_ICALL                                         $15     
         19        ASSIGN                                                   !2, $15
    9    20        ASSIGN                                                   !3, <array>
         21      > JMP                                                      ->45
   10    22    >   INIT_METHOD_CALL                                         !1, 'format'
         23        SEND_VAL_EX                                              'W-Y'
         24        DO_FCALL                                      0  $18     
         25        ASSIGN                                                   !4, $18
   11    26        INIT_METHOD_CALL                                         !1, 'format'
         27        SEND_VAL_EX                                              'd%2Fm%2FY'
         28        DO_FCALL                                      0  $20     
         29        ASSIGN                                                   !5, $20
   12    30        CLONE                                            ~22     !1
         31        INIT_METHOD_CALL                                         ~22, 'modify'
         32        SEND_VAL_EX                                              '%2B6+Days'
         33        DO_FCALL                                      0  $23     
         34        INIT_METHOD_CALL                                         $23, 'format'
         35        SEND_VAL_EX                                              'd%2Fm%2FY'
         36        DO_FCALL                                      0  $24     
         37        ASSIGN                                                   !6, $24
   13    38        CONCAT                                           ~27     !5, '+-+'
         39        CONCAT                                           ~28     ~27, !6
         40        ASSIGN_DIM                                               !3, !4
         41        OP_DATA                                                  ~28
    9    42        INIT_METHOD_CALL                                         !1, 'modify'
         43        SEND_VAL_EX                                              '%2B1+week'
         44        DO_FCALL                                      0          
         45    >   IS_SMALLER_OR_EQUAL                                      !1, !2
         46      > JMPNZ                                                    ~30, ->22
   16    47    >   INIT_FCALL                                               'var_export'
         48        SEND_VAR                                                 !3
         49        DO_ICALL                                                 
         50      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.14 ms | 1016 KiB | 15 Q