3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('UTC'); //to be sure that DateInterval will work as intended $today = new DateTime; $fist_day_of_the_month = $today->format('Y-m-01'); $range = new DatePeriod( new DateTime($fist_day_of_the_month), //begin new DateInterval('P1M'), //interval 23 //nb recurrences ); foreach ($range as $date) { echo $date->format('Y-m-d'), PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 30
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 30
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/A6tNQ
function name:  (null)
number of ops:  32
compiled vars:  !0 = $today, !1 = $fist_day_of_the_month, !2 = $range, !3 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'date_default_timezone_set'
          1        SEND_VAL                                                 'UTC'
          2        DO_ICALL                                                 
    5     3        NEW                                              $5      'DateTime'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $5
    6     6        INIT_METHOD_CALL                                         !0, 'format'
          7        SEND_VAL_EX                                              'Y-m-01'
          8        DO_FCALL                                      0  $8      
          9        ASSIGN                                                   !1, $8
    8    10        NEW                                              $10     'DatePeriod'
    9    11        NEW                                              $11     'DateTime'
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0          
         14        SEND_VAR_NO_REF_EX                                       $11
   10    15        NEW                                              $13     'DateInterval'
         16        SEND_VAL_EX                                              'P1M'
         17        DO_FCALL                                      0          
         18        SEND_VAR_NO_REF_EX                                       $13
   11    19        SEND_VAL_EX                                              23
         20        DO_FCALL                                      0          
    8    21        ASSIGN                                                   !2, $10
   14    22      > FE_RESET_R                                       $17     !2, ->30
         23    > > FE_FETCH_R                                               $17, !3, ->30
   15    24    >   INIT_METHOD_CALL                                         !3, 'format'
         25        SEND_VAL_EX                                              'Y-m-d'
         26        DO_FCALL                                      0  $18     
         27        ECHO                                                     $18
         28        ECHO                                                     '%0A'
   14    29      > JMP                                                      ->23
         30    >   FE_FREE                                                  $17
   16    31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.59 ms | 1396 KiB | 15 Q