3v4l.org

run code in 300+ PHP versions simultaneously
<?php $begin_date = new DateTime('2016-01-01 00:00:00'); $end_date = new DateTime('2017-05-02 23:59:59'); $result = array(); $current = clone $begin_date; while ($current < $end_date) { array_push($result, $current->format('Y-m')); $current->add(DateInterval::createFromDateString('1 Month')); } var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 12
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 12
Branch analysis from position: 27
Branch analysis from position: 12
filename:       /in/sZ0U5
function name:  (null)
number of ops:  31
compiled vars:  !0 = $begin_date, !1 = $end_date, !2 = $result, !3 = $current
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $4      'DateTime'
          1        SEND_VAL_EX                                              '2016-01-01+00%3A00%3A00'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $4
    4     4        NEW                                              $7      'DateTime'
          5        SEND_VAL_EX                                              '2017-05-02+23%3A59%3A59'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $7
    5     8        ASSIGN                                                   !2, <array>
    6     9        CLONE                                            ~11     !0
         10        ASSIGN                                                   !3, ~11
    7    11      > JMP                                                      ->25
    8    12    >   INIT_FCALL                                               'array_push'
         13        SEND_REF                                                 !2
         14        INIT_METHOD_CALL                                         !3, 'format'
         15        SEND_VAL_EX                                              'Y-m'
         16        DO_FCALL                                      0  $13     
         17        SEND_VAR                                                 $13
         18        DO_ICALL                                                 
    9    19        INIT_METHOD_CALL                                         !3, 'add'
         20        INIT_STATIC_METHOD_CALL                                  'DateInterval', 'createFromDateString'
         21        SEND_VAL                                                 '1+Month'
         22        DO_FCALL                                      0  $15     
         23        SEND_VAR_NO_REF_EX                                       $15
         24        DO_FCALL                                      0          
    7    25    >   IS_SMALLER                                               !3, !1
         26      > JMPNZ                                                    ~17, ->12
   11    27    >   INIT_FCALL                                               'var_dump'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.43 ms | 1401 KiB | 17 Q