3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = new \DateTime('first day of this month'); $end = (new \DateTime('first day of this month'))->modify('+18 months'); $interval = new \DateInterval('P1M'); $period = new \DatePeriod($start, $interval, $end); foreach ($period as $month) { $lastDayOfMonth = $month->format('t'); $day = (date('d') > $lastDayOfMonth) ? $lastDayOfMonth : date('d'); echo $month->format("n | Y | Y-m-{$day}"); echo "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 47
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 47
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
filename:       /in/TSn81
function name:  (null)
number of ops:  49
compiled vars:  !0 = $start, !1 = $end, !2 = $interval, !3 = $period, !4 = $month, !5 = $lastDayOfMonth, !6 = $day
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $7      'DateTime'
          1        SEND_VAL_EX                                              'first+day+of+this+month'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $7
    4     4        NEW                                              $10     'DateTime'
          5        SEND_VAL_EX                                              'first+day+of+this+month'
          6        DO_FCALL                                      0          
          7        INIT_METHOD_CALL                                         $10, 'modify'
          8        SEND_VAL_EX                                              '%2B18+months'
          9        DO_FCALL                                      0  $12     
         10        ASSIGN                                                   !1, $12
    5    11        NEW                                              $14     'DateInterval'
         12        SEND_VAL_EX                                              'P1M'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !2, $14
    6    15        NEW                                              $17     'DatePeriod'
         16        SEND_VAR_EX                                              !0
         17        SEND_VAR_EX                                              !2
         18        SEND_VAR_EX                                              !1
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !3, $17
    7    21      > FE_RESET_R                                       $20     !3, ->47
         22    > > FE_FETCH_R                                               $20, !4, ->47
    8    23    >   INIT_METHOD_CALL                                         !4, 'format'
         24        SEND_VAL_EX                                              't'
         25        DO_FCALL                                      0  $21     
         26        ASSIGN                                                   !5, $21
    9    27        INIT_FCALL                                               'date'
         28        SEND_VAL                                                 'd'
         29        DO_ICALL                                         $23     
         30        IS_SMALLER                                               !5, $23
         31      > JMPZ                                                     ~24, ->34
         32    >   QM_ASSIGN                                        ~25     !5
         33      > JMP                                                      ->38
         34    >   INIT_FCALL                                               'date'
         35        SEND_VAL                                                 'd'
         36        DO_ICALL                                         $26     
         37        QM_ASSIGN                                        ~25     $26
         38    >   ASSIGN                                                   !6, ~25
   10    39        INIT_METHOD_CALL                                         !4, 'format'
         40        NOP                                                      
         41        FAST_CONCAT                                      ~28     'n+%7C+Y+%7C+Y-m-', !6
         42        SEND_VAL_EX                                              ~28
         43        DO_FCALL                                      0  $29     
         44        ECHO                                                     $29
   11    45        ECHO                                                     '%0A'
    7    46      > JMP                                                      ->22
         47    >   FE_FREE                                                  $20
   12    48      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.1 ms | 1007 KiB | 14 Q