3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dow = 'saturday'; $step = 2; $unit = 'W'; $start = new DateTime(time()); $end = clone $start; $start->modify($dow); // Move to first occurence $end->add(new DateInterval('P1Y')); // Move to 1 year from start $interval = new DateInterval("P{$step}{$unit}"); $period = new DatePeriod($start, $interval, $end); foreach ($period as $date) { echo $date->format('D, d M Y'), PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 34, Position 2 = 41
Branch analysis from position: 34
2 jumps found. (Code = 78) Position 1 = 35, Position 2 = 41
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/Zuqn8
function name:  (null)
number of ops:  43
compiled vars:  !0 = $dow, !1 = $step, !2 = $unit, !3 = $start, !4 = $end, !5 = $interval, !6 = $period, !7 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'saturday'
    3     1        ASSIGN                                                   !1, 2
    4     2        ASSIGN                                                   !2, 'W'
    6     3        NEW                                              $11     'DateTime'
          4        INIT_FCALL                                               'time'
          5        DO_ICALL                                         $12     
          6        SEND_VAR_NO_REF_EX                                       $12
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !3, $11
    7     9        CLONE                                            ~15     !3
         10        ASSIGN                                                   !4, ~15
    9    11        INIT_METHOD_CALL                                         !3, 'modify'
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0          
   10    14        INIT_METHOD_CALL                                         !4, 'add'
         15        NEW                                              $18     'DateInterval'
         16        SEND_VAL_EX                                              'P1Y'
         17        DO_FCALL                                      0          
         18        SEND_VAR_NO_REF_EX                                       $18
         19        DO_FCALL                                      0          
   12    20        NEW                                              $21     'DateInterval'
         21        ROPE_INIT                                     3  ~23     'P'
         22        ROPE_ADD                                      1  ~23     ~23, !1
         23        ROPE_END                                      2  ~22     ~23, !2
         24        SEND_VAL_EX                                              ~22
         25        DO_FCALL                                      0          
         26        ASSIGN                                                   !5, $21
   13    27        NEW                                              $27     'DatePeriod'
         28        SEND_VAR_EX                                              !3
         29        SEND_VAR_EX                                              !5
         30        SEND_VAR_EX                                              !4
         31        DO_FCALL                                      0          
         32        ASSIGN                                                   !6, $27
   15    33      > FE_RESET_R                                       $30     !6, ->41
         34    > > FE_FETCH_R                                               $30, !7, ->41
   16    35    >   INIT_METHOD_CALL                                         !7, 'format'
         36        SEND_VAL_EX                                              'D%2C+d+M+Y'
         37        DO_FCALL                                      0  $31     
         38        ECHO                                                     $31
         39        ECHO                                                     '%0A'
   15    40      > JMP                                                      ->34
         41    >   FE_FREE                                                  $30
   17    42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.92 ms | 1400 KiB | 15 Q