3v4l.org

run code in 300+ PHP versions simultaneously
<?php $day = 'saturday'; $step = 2; $unit = 'W'; $start = new DateTime(); $end = clone $start; $start->modify($day); // 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, H:m:s'), PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 38
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 38
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/0JE61
function name:  (null)
number of ops:  40
compiled vars:  !0 = $day, !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        DO_FCALL                                      0          
          5        ASSIGN                                                   !3, $11
    7     6        CLONE                                            ~14     !3
          7        ASSIGN                                                   !4, ~14
    9     8        INIT_METHOD_CALL                                         !3, 'modify'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
   10    11        INIT_METHOD_CALL                                         !4, 'add'
         12        NEW                                              $17     'DateInterval'
         13        SEND_VAL_EX                                              'P1Y'
         14        DO_FCALL                                      0          
         15        SEND_VAR_NO_REF_EX                                       $17
         16        DO_FCALL                                      0          
   12    17        NEW                                              $20     'DateInterval'
         18        ROPE_INIT                                     3  ~22     'P'
         19        ROPE_ADD                                      1  ~22     ~22, !1
         20        ROPE_END                                      2  ~21     ~22, !2
         21        SEND_VAL_EX                                              ~21
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !5, $20
   13    24        NEW                                              $26     'DatePeriod'
         25        SEND_VAR_EX                                              !3
         26        SEND_VAR_EX                                              !5
         27        SEND_VAR_EX                                              !4
         28        DO_FCALL                                      0          
         29        ASSIGN                                                   !6, $26
   15    30      > FE_RESET_R                                       $29     !6, ->38
         31    > > FE_FETCH_R                                               $29, !7, ->38
   16    32    >   INIT_METHOD_CALL                                         !7, 'format'
         33        SEND_VAL_EX                                              'D%2C+d+M+Y%2C+H%3Am%3As'
         34        DO_FCALL                                      0  $30     
         35        ECHO                                                     $30
         36        ECHO                                                     '%0A'
   15    37      > JMP                                                      ->31
         38    >   FE_FREE                                                  $29
   17    39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
247.46 ms | 1399 KiB | 14 Q