3v4l.org

run code in 300+ PHP versions simultaneously
<?php $excludedRanges = [ ['2017-07-20', '2017-07-21', 'Python', true], ['2017-08-14', '2017-08-15', 'Python', true], ['2017-09-04', '2017-09-08', 'Joris en de Draak', true], ['2017-09-04', '2017-11-28', 'De Tuinman en de Fakir', false], ['2017-09-04', '2017-09-04', 'Spookslot', false], ['2017-09-11', '2017-09-22', 'Fata Morgana', true], ['2017-09-11', '2017-12-01', 'Python', true], ['2017-09-11', '2017-09-15', 'De Oude Tufferbaan', false], ['2017-09-25', '2017-09-29', 'Carnaval Festival', false], ['2017-10-02', '2017-10-06', 'Villa Volta', false], ['2017-10-02', '2017-10-13', 'Gondoletta', false], ['2017-10-07', '2017-10-13', 'Aquanura', false], ]; $startDate = '2017-09-01'; $endDate = '2017-11-30'; $startDay = date('z', strtotime($startDate)); $endDay = date('z', strtotime($endDate)); for($i = $startDay, $j = 0; $i <= $endDay; $i++, $j++) { $date = date("Y-m-d", strtotime($startDate . " +" . $j . ' days')); $dayOfWeek = date("w", strtotime($date)); # Only wednesdays and saturdays if ($dayOfWeek !== 3 || $dayOfWeek !== 5) { continue; } if (($closed = isAnAttractionClosed($i, $excludedRanges)) !== false) { echo $date . ': ' . $closed[2] . ' gesloten. ' . ($closed[3] ? 'Nee' : 'Liever niet') . PHP_EOL; continue; } echo $date . ': Ja' . PHP_EOL; } /** * @param int $dayOfTheYear * @param array $closedAttractions * @return bool */ function isAnAttractionClosed($dayOfTheYear, $closedAttractions) { foreach ($closedAttractions as $closed) { $start = date('z', strtotime($closed[0])); $end = date('z', strtotime($closed[1])); if ($dayOfTheYear >= $start && $dayOfTheYear <= $end) { return $closed; } } return false; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 22
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 47) Position 1 = 43, Position 2 = 45
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 47
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 22
Branch analysis from position: 74
Branch analysis from position: 22
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 67
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 62
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
Branch analysis from position: 67
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 22
Branch analysis from position: 74
Branch analysis from position: 22
Branch analysis from position: 45
filename:       /in/UaDTT
function name:  (null)
number of ops:  75
compiled vars:  !0 = $excludedRanges, !1 = $startDate, !2 = $endDate, !3 = $startDay, !4 = $endDay, !5 = $i, !6 = $j, !7 = $date, !8 = $dayOfWeek, !9 = $closed
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   18     1        ASSIGN                                                   !1, '2017-09-01'
   19     2        ASSIGN                                                   !2, '2017-11-30'
   21     3        INIT_FCALL                                               'date'
          4        SEND_VAL                                                 'z'
          5        INIT_FCALL                                               'strtotime'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $13     
          8        SEND_VAR                                                 $13
          9        DO_ICALL                                         $14     
         10        ASSIGN                                                   !3, $14
   22    11        INIT_FCALL                                               'date'
         12        SEND_VAL                                                 'z'
         13        INIT_FCALL                                               'strtotime'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                         $16     
         16        SEND_VAR                                                 $16
         17        DO_ICALL                                         $17     
         18        ASSIGN                                                   !4, $17
   24    19        ASSIGN                                                   !5, !3
         20        ASSIGN                                                   !6, 0
         21      > JMP                                                      ->72
   25    22    >   INIT_FCALL                                               'date'
         23        SEND_VAL                                                 'Y-m-d'
         24        INIT_FCALL                                               'strtotime'
         25        CONCAT                                           ~21     !1, '+%2B'
         26        CONCAT                                           ~22     ~21, !6
         27        CONCAT                                           ~23     ~22, '+days'
         28        SEND_VAL                                                 ~23
         29        DO_ICALL                                         $24     
         30        SEND_VAR                                                 $24
         31        DO_ICALL                                         $25     
         32        ASSIGN                                                   !7, $25
   26    33        INIT_FCALL                                               'date'
         34        SEND_VAL                                                 'w'
         35        INIT_FCALL                                               'strtotime'
         36        SEND_VAR                                                 !7
         37        DO_ICALL                                         $27     
         38        SEND_VAR                                                 $27
         39        DO_ICALL                                         $28     
         40        ASSIGN                                                   !8, $28
   29    41        IS_NOT_IDENTICAL                                 ~30     !8, 3
         42      > JMPNZ_EX                                         ~30     ~30, ->45
         43    >   IS_NOT_IDENTICAL                                 ~31     !8, 5
         44        BOOL                                             ~30     ~31
         45    > > JMPZ                                                     ~30, ->47
   30    46    > > JMP                                                      ->70
   33    47    >   INIT_FCALL_BY_NAME                                       'isAnAttractionClosed'
         48        SEND_VAR_EX                                              !5
         49        SEND_VAR_EX                                              !0
         50        DO_FCALL                                      0  $32     
         51        ASSIGN                                           ~33     !9, $32
         52        TYPE_CHECK                                  1018          ~33
         53      > JMPZ                                                     ~34, ->67
   34    54    >   CONCAT                                           ~35     !7, '%3A+'
         55        FETCH_DIM_R                                      ~36     !9, 2
         56        CONCAT                                           ~37     ~35, ~36
         57        CONCAT                                           ~38     ~37, '+gesloten.+'
         58        FETCH_DIM_R                                      ~39     !9, 3
         59      > JMPZ                                                     ~39, ->62
         60    >   QM_ASSIGN                                        ~40     'Nee'
         61      > JMP                                                      ->63
         62    >   QM_ASSIGN                                        ~40     'Liever+niet'
         63    >   CONCAT                                           ~41     ~38, ~40
         64        CONCAT                                           ~42     ~41, '%0A'
         65        ECHO                                                     ~42
   35    66      > JMP                                                      ->70
   39    67    >   CONCAT                                           ~43     !7, '%3A+Ja'
         68        CONCAT                                           ~44     ~43, '%0A'
         69        ECHO                                                     ~44
   24    70    >   PRE_INC                                                  !5
         71        PRE_INC                                                  !6
         72    >   IS_SMALLER_OR_EQUAL                                      !5, !4
         73      > JMPNZ                                                    ~47, ->22
   58    74    > > RETURN                                                   1

Function isanattractionclosed:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 30
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 30
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 26
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/UaDTT
function name:  isAnAttractionClosed
number of ops:  33
compiled vars:  !0 = $dayOfTheYear, !1 = $closedAttractions, !2 = $closed, !3 = $start, !4 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   48     2      > FE_RESET_R                                       $5      !1, ->30
          3    > > FE_FETCH_R                                               $5, !2, ->30
   49     4    >   INIT_FCALL                                               'date'
          5        SEND_VAL                                                 'z'
          6        INIT_FCALL                                               'strtotime'
          7        FETCH_DIM_R                                      ~6      !2, 0
          8        SEND_VAL                                                 ~6
          9        DO_ICALL                                         $7      
         10        SEND_VAR                                                 $7
         11        DO_ICALL                                         $8      
         12        ASSIGN                                                   !3, $8
   50    13        INIT_FCALL                                               'date'
         14        SEND_VAL                                                 'z'
         15        INIT_FCALL                                               'strtotime'
         16        FETCH_DIM_R                                      ~10     !2, 1
         17        SEND_VAL                                                 ~10
         18        DO_ICALL                                         $11     
         19        SEND_VAR                                                 $11
         20        DO_ICALL                                         $12     
         21        ASSIGN                                                   !4, $12
   52    22        IS_SMALLER_OR_EQUAL                              ~14     !3, !0
         23      > JMPZ_EX                                          ~14     ~14, ->26
         24    >   IS_SMALLER_OR_EQUAL                              ~15     !0, !4
         25        BOOL                                             ~14     ~15
         26    > > JMPZ                                                     ~14, ->29
   53    27    >   FE_FREE                                                  $5
         28      > RETURN                                                   !2
   48    29    > > JMP                                                      ->3
         30    >   FE_FREE                                                  $5
   57    31      > RETURN                                                   <false>
   58    32*     > RETURN                                                   null

End of function isanattractionclosed

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.94 ms | 1404 KiB | 17 Q