3v4l.org

run code in 300+ PHP versions simultaneously
<?php $recur = 'FREQ=WEEKLY;BYDAY=TU'; $ex = explode(';', $recur); $freq = str_replace('FREQ=','',$ex[0]); $day = str_replace('BYDAY=','',$ex[1]); $dates = []; switch ($freq) { case 'WEEKLY': $date = new DateTime(); // set to correct day obvs $dates[] = $date; for ($x = 0; $x <= 52; $x ++) { $date = clone $date; $date->modify('+1 week'); $dates[] = $date; } break; } foreach($dates as $date) { echo $date->format('Y-m-d')."\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 77) Position 1 = 43, Position 2 = 50
Branch analysis from position: 43
2 jumps found. (Code = 78) Position 1 = 44, Position 2 = 50
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 31
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 31
Branch analysis from position: 41
Branch analysis from position: 31
filename:       /in/Dgriv
function name:  (null)
number of ops:  52
compiled vars:  !0 = $recur, !1 = $ex, !2 = $freq, !3 = $day, !4 = $dates, !5 = $date, !6 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'FREQ%3DWEEKLY%3BBYDAY%3DTU'
    4     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%3B'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !1, $8
    5     6        INIT_FCALL                                               'str_replace'
          7        SEND_VAL                                                 'FREQ%3D'
          8        SEND_VAL                                                 ''
          9        FETCH_DIM_R                                      ~10     !1, 0
         10        SEND_VAL                                                 ~10
         11        DO_ICALL                                         $11     
         12        ASSIGN                                                   !2, $11
    6    13        INIT_FCALL                                               'str_replace'
         14        SEND_VAL                                                 'BYDAY%3D'
         15        SEND_VAL                                                 ''
         16        FETCH_DIM_R                                      ~13     !1, 1
         17        SEND_VAL                                                 ~13
         18        DO_ICALL                                         $14     
         19        ASSIGN                                                   !3, $14
    8    20        ASSIGN                                                   !4, <array>
   11    21        IS_EQUAL                                                 !2, 'WEEKLY'
         22      > JMPNZ                                                    ~17, ->24
         23    > > JMP                                                      ->42
   12    24    >   NEW                                              $18     'DateTime'
         25        DO_FCALL                                      0          
         26        ASSIGN                                                   !5, $18
   13    27        ASSIGN_DIM                                               !4
         28        OP_DATA                                                  !5
   14    29        ASSIGN                                                   !6, 0
         30      > JMP                                                      ->39
   15    31    >   CLONE                                            ~23     !5
         32        ASSIGN                                                   !5, ~23
   16    33        INIT_METHOD_CALL                                         !5, 'modify'
         34        SEND_VAL_EX                                              '%2B1+week'
         35        DO_FCALL                                      0          
   17    36        ASSIGN_DIM                                               !4
         37        OP_DATA                                                  !5
   14    38        PRE_INC                                                  !6
         39    >   IS_SMALLER_OR_EQUAL                                      !6, 52
         40      > JMPNZ                                                    ~28, ->31
   19    41    > > JMP                                                      ->42
   22    42    > > FE_RESET_R                                       $29     !4, ->50
         43    > > FE_FETCH_R                                               $29, !5, ->50
   23    44    >   INIT_METHOD_CALL                                         !5, 'format'
         45        SEND_VAL_EX                                              'Y-m-d'
         46        DO_FCALL                                      0  $30     
         47        CONCAT                                           ~31     $30, '%0A'
         48        ECHO                                                     ~31
   22    49      > JMP                                                      ->43
         50    >   FE_FREE                                                  $29
   24    51      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.15 ms | 1004 KiB | 15 Q