3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = new DateTime('2010-12-02'); $start_first_day = $start->modify('first day of this month'); $end = new DateTime('2012-05-06'); $end->modify('first day of next month'); $interval = DateInterval::createFromDateString('1 month'); $period = new DatePeriod($start_first_day , $interval, $end); foreach ($period as $dt) { $month_start = $dt->format("Y-m-d"); $month_end = $dt->modify('last day of this month'); $month_end = $month_end ->format("Y-m-d"); echo $month_start . " " . $month_end . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 44
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 44
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
filename:       /in/omaIr
function name:  (null)
number of ops:  46
compiled vars:  !0 = $start, !1 = $start_first_day, !2 = $end, !3 = $interval, !4 = $period, !5 = $dt, !6 = $month_start, !7 = $month_end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   NEW                                              $8      'DateTime'
          1        SEND_VAL_EX                                              '2010-12-02'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $8
    3     4        INIT_METHOD_CALL                                         !0, 'modify'
          5        SEND_VAL_EX                                              'first+day+of+this+month'
          6        DO_FCALL                                      0  $11     
          7        ASSIGN                                                   !1, $11
    4     8        NEW                                              $13     'DateTime'
          9        SEND_VAL_EX                                              '2012-05-06'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $13
    5    12        INIT_METHOD_CALL                                         !2, 'modify'
         13        SEND_VAL_EX                                              'first+day+of+next+month'
         14        DO_FCALL                                      0          
    6    15        INIT_STATIC_METHOD_CALL                                  'DateInterval', 'createFromDateString'
         16        SEND_VAL                                                 '1+month'
         17        DO_FCALL                                      0  $17     
         18        ASSIGN                                                   !3, $17
    7    19        NEW                                              $19     'DatePeriod'
         20        SEND_VAR_EX                                              !1
         21        SEND_VAR_EX                                              !3
         22        SEND_VAR_EX                                              !2
         23        DO_FCALL                                      0          
         24        ASSIGN                                                   !4, $19
    9    25      > FE_RESET_R                                       $22     !4, ->44
         26    > > FE_FETCH_R                                               $22, !5, ->44
   10    27    >   INIT_METHOD_CALL                                         !5, 'format'
         28        SEND_VAL_EX                                              'Y-m-d'
         29        DO_FCALL                                      0  $23     
         30        ASSIGN                                                   !6, $23
   11    31        INIT_METHOD_CALL                                         !5, 'modify'
         32        SEND_VAL_EX                                              'last+day+of+this+month'
         33        DO_FCALL                                      0  $25     
         34        ASSIGN                                                   !7, $25
   12    35        INIT_METHOD_CALL                                         !7, 'format'
         36        SEND_VAL_EX                                              'Y-m-d'
         37        DO_FCALL                                      0  $27     
         38        ASSIGN                                                   !7, $27
   13    39        CONCAT                                           ~29     !6, '+'
         40        CONCAT                                           ~30     ~29, !7
         41        CONCAT                                           ~31     ~30, '%0A'
         42        ECHO                                                     ~31
    9    43      > JMP                                                      ->26
         44    >   FE_FREE                                                  $22
   14    45      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.87 ms | 1399 KiB | 13 Q