3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = new DateTime(''); $end = new DateTime('+7 days'); $interval = new DateInterval('P0D'); $period = new DatePeriod($start, $interval, $end); $safety = 0; foreach ($period as $dt) { $safety++; if ($dt->format("N") === 7) { $end->add(new DateInterval('P2D')); } else { echo $dt->format("l Y-m-d") . PHP_EOL; } if ($safety > 7) { break; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 43
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 43
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 34
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 42
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 42
Branch analysis from position: 41
Branch analysis from position: 42
Branch analysis from position: 43
Branch analysis from position: 43
filename:       /in/N9lqB
function name:  (null)
number of ops:  45
compiled vars:  !0 = $start, !1 = $end, !2 = $interval, !3 = $period, !4 = $safety, !5 = $dt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   NEW                                              $6      'DateTime'
          1        SEND_VAL_EX                                              ''
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $6
    3     4        NEW                                              $9      'DateTime'
          5        SEND_VAL_EX                                              '%2B7+days'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $9
    4     8        NEW                                              $12     'DateInterval'
          9        SEND_VAL_EX                                              'P0D'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $12
    5    12        NEW                                              $15     'DatePeriod'
         13        SEND_VAR_EX                                              !0
         14        SEND_VAR_EX                                              !2
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !3, $15
    7    18        ASSIGN                                                   !4, 0
    9    19      > FE_RESET_R                                       $19     !3, ->43
         20    > > FE_FETCH_R                                               $19, !5, ->43
   11    21    >   PRE_INC                                                  !4
   12    22        INIT_METHOD_CALL                                         !5, 'format'
         23        SEND_VAL_EX                                              'N'
         24        DO_FCALL                                      0  $21     
         25        IS_IDENTICAL                                             $21, 7
         26      > JMPZ                                                     ~22, ->34
   14    27    >   INIT_METHOD_CALL                                         !1, 'add'
         28        NEW                                              $23     'DateInterval'
         29        SEND_VAL_EX                                              'P2D'
         30        DO_FCALL                                      0          
         31        SEND_VAR_NO_REF_EX                                       $23
         32        DO_FCALL                                      0          
         33      > JMP                                                      ->39
   18    34    >   INIT_METHOD_CALL                                         !5, 'format'
         35        SEND_VAL_EX                                              'l+Y-m-d'
         36        DO_FCALL                                      0  $26     
         37        CONCAT                                           ~27     $26, '%0A'
         38        ECHO                                                     ~27
   21    39    >   IS_SMALLER                                               7, !4
         40      > JMPZ                                                     ~28, ->42
   23    41    > > JMP                                                      ->43
    9    42    > > JMP                                                      ->20
         43    >   FE_FREE                                                  $19
   25    44      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.78 ms | 1399 KiB | 13 Q