3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.86 ms | 1400 KiB | 15 Q