3v4l.org

run code in 500+ PHP versions simultaneously
<?php $ordinalHolidays = [ 'thanksgiving' => 'fourth Thursday of November', 'blackfriday' => 'fourth Thursday of November + 1 day' ]; $startDate = new \DateTimeImmutable('2016-04-20'); $periods = new \DatePeriod($startDate, new \DateInterval('P1Y'), 5); foreach ($periods as $date) { echo 'Holidays for ' . $date->format('Y') . \PHP_EOL; foreach ($ordinalHolidays as $holiday => $ordinalHoliday) { $holidayDate = $date->modify($ordinalHoliday); echo $holiday . ' is ' . $holidayDate->format('Y-m-d') . \PHP_EOL; } echo \PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 40
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 40
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 37
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 37
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 37
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
filename:       /in/pra1L
function name:  (null)
number of ops:  42
compiled vars:  !0 = $ordinalHolidays, !1 = $startDate, !2 = $periods, !3 = $date, !4 = $ordinalHoliday, !5 = $holiday, !6 = $holidayDate
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    9     1        NEW                                                  $8      'DateTimeImmutable'
          2        SEND_VAL_EX                                                  '2016-04-20'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !1, $8
   11     5        NEW                                                  $11     'DatePeriod'
          6        SEND_VAR_EX                                                  !1
          7        NEW                                                  $12     'DateInterval'
          8        SEND_VAL_EX                                                  'P1Y'
          9        DO_FCALL                                          0          
         10        SEND_VAR_NO_REF_EX                                           $12
         11        SEND_VAL_EX                                                  5
         12        DO_FCALL                                          0          
         13        ASSIGN                                                       !2, $11
   12    14      > FE_RESET_R                                           $16     !2, ->40
         15    > > FE_FETCH_R                                                   $16, !3, ->40
   13    16    >   INIT_METHOD_CALL                                             !3, 'format'
         17        SEND_VAL_EX                                                  'Y'
         18        DO_FCALL                                          0  $17     
         19        CONCAT                                               ~18     'Holidays+for+', $17
         20        CONCAT                                               ~19     ~18, '%0A'
         21        ECHO                                                         ~19
   14    22      > FE_RESET_R                                           $20     !0, ->37
         23    > > FE_FETCH_R                                           ~21     $20, !4, ->37
         24    >   ASSIGN                                                       !5, ~21
   15    25        INIT_METHOD_CALL                                             !3, 'modify'
         26        SEND_VAR_EX                                                  !4
         27        DO_FCALL                                          0  $23     
         28        ASSIGN                                                       !6, $23
   16    29        CONCAT                                               ~25     !5, '+is+'
         30        INIT_METHOD_CALL                                             !6, 'format'
         31        SEND_VAL_EX                                                  'Y-m-d'
         32        DO_FCALL                                          0  $26     
         33        CONCAT                                               ~27     ~25, $26
         34        CONCAT                                               ~28     ~27, '%0A'
         35        ECHO                                                         ~28
   14    36      > JMP                                                          ->23
         37    >   FE_FREE                                                      $20
   18    38        ECHO                                                         '%0A'
   12    39      > JMP                                                          ->15
         40    >   FE_FREE                                                      $16
   19    41      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
157.5 ms | 2134 KiB | 13 Q