3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dates = []; $end = new DateTimeImmutable('Thursday'); $start = $end->modify('-6 weeks'); $interval = new DateInterval('P1W'); $period = new DatePeriod($start, $interval, $end); foreach ($period as $date) { $wednesday = $date->modify('Wednesday'); $dates[] = sprintf('%s - %s%s', $date->format('D j M'), $wednesday->format('D j M'), PHP_EOL); } $dates = array_reverse($dates); foreach ($dates as $week) { echo $week; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 40
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 40
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 40
2 jumps found. (Code = 77) Position 1 = 46, Position 2 = 49
Branch analysis from position: 46
2 jumps found. (Code = 78) Position 1 = 47, Position 2 = 49
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
Branch analysis from position: 40
filename:       /in/NRcOq
function name:  (null)
number of ops:  51
compiled vars:  !0 = $dates, !1 = $end, !2 = $start, !3 = $interval, !4 = $period, !5 = $date, !6 = $wednesday, !7 = $week
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        NEW                                              $9      'DateTimeImmutable'
          2        SEND_VAL_EX                                              'Thursday'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $9
    4     5        INIT_METHOD_CALL                                         !1, 'modify'
          6        SEND_VAL_EX                                              '-6+weeks'
          7        DO_FCALL                                      0  $12     
          8        ASSIGN                                                   !2, $12
    5     9        NEW                                              $14     'DateInterval'
         10        SEND_VAL_EX                                              'P1W'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !3, $14
    6    13        NEW                                              $17     'DatePeriod'
         14        SEND_VAR_EX                                              !2
         15        SEND_VAR_EX                                              !3
         16        SEND_VAR_EX                                              !1
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !4, $17
    7    19      > FE_RESET_R                                       $20     !4, ->40
         20    > > FE_FETCH_R                                               $20, !5, ->40
    8    21    >   INIT_METHOD_CALL                                         !5, 'modify'
         22        SEND_VAL_EX                                              'Wednesday'
         23        DO_FCALL                                      0  $21     
         24        ASSIGN                                                   !6, $21
    9    25        INIT_FCALL                                               'sprintf'
         26        SEND_VAL                                                 '%25s+-+%25s%25s'
         27        INIT_METHOD_CALL                                         !5, 'format'
         28        SEND_VAL_EX                                              'D+j+M'
         29        DO_FCALL                                      0  $24     
         30        SEND_VAR                                                 $24
         31        INIT_METHOD_CALL                                         !6, 'format'
         32        SEND_VAL_EX                                              'D+j+M'
         33        DO_FCALL                                      0  $25     
         34        SEND_VAR                                                 $25
         35        SEND_VAL                                                 '%0A'
         36        DO_ICALL                                         $26     
         37        ASSIGN_DIM                                               !0
         38        OP_DATA                                                  $26
    7    39      > JMP                                                      ->20
         40    >   FE_FREE                                                  $20
   11    41        INIT_FCALL                                               'array_reverse'
         42        SEND_VAR                                                 !0
         43        DO_ICALL                                         $27     
         44        ASSIGN                                                   !0, $27
   12    45      > FE_RESET_R                                       $29     !0, ->49
         46    > > FE_FETCH_R                                               $29, !7, ->49
   13    47    >   ECHO                                                     !7
   12    48      > JMP                                                      ->46
         49    >   FE_FREE                                                  $29
   14    50      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.08 ms | 1016 KiB | 15 Q