3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); $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 = 75
Branch analysis from position: 75
2 jumps found. (Code = 44) Position 1 = 77, Position 2 = 25
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 46) Position 1 = 46, Position 2 = 48
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 50
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
2 jumps found. (Code = 44) Position 1 = 77, Position 2 = 25
Branch analysis from position: 77
Branch analysis from position: 25
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 70
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 65
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 77, Position 2 = 25
Branch analysis from position: 77
Branch analysis from position: 25
Branch analysis from position: 48
filename:       /in/2uHAB
function name:  (null)
number of ops:  78
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 >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 32767
          2        DO_ICALL                                                 
    5     3        ASSIGN                                                   !0, <array>
   20     4        ASSIGN                                                   !1, '2017-09-01'
   21     5        ASSIGN                                                   !2, '2017-11-30'
   23     6        INIT_FCALL                                               'date'
          7        SEND_VAL                                                 'z'
          8        INIT_FCALL                                               'strtotime'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $14     
         11        SEND_VAR                                                 $14
         12        DO_ICALL                                         $15     
         13        ASSIGN                                                   !3, $15
   24    14        INIT_FCALL                                               'date'
         15        SEND_VAL                                                 'z'
         16        INIT_FCALL                                               'strtotime'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                         $17     
         19        SEND_VAR                                                 $17
         20        DO_ICALL                                         $18     
         21        ASSIGN                                                   !4, $18
   26    22        ASSIGN                                                   !5, !3
         23        ASSIGN                                                   !6, 0
         24      > JMP                                                      ->75
   27    25    >   INIT_FCALL                                               'date'
         26        SEND_VAL                                                 'Y-m-d'
         27        INIT_FCALL                                               'strtotime'
         28        CONCAT                                           ~22     !1, '+%2B'
         29        CONCAT                                           ~23     ~22, !6
         30        CONCAT                                           ~24     ~23, '+days'
         31        SEND_VAL                                                 ~24
         32        DO_ICALL                                         $25     
         33        SEND_VAR                                                 $25
         34        DO_ICALL                                         $26     
         35        ASSIGN                                                   !7, $26
   28    36        INIT_FCALL                                               'date'
         37        SEND_VAL                                                 'w'
         38        INIT_FCALL                                               'strtotime'
         39        SEND_VAR                                                 !7
         40        DO_ICALL                                         $28     
         41        SEND_VAR                                                 $28
         42        DO_ICALL                                         $29     
         43        ASSIGN                                                   !8, $29
   31    44        IS_NOT_IDENTICAL                                 ~31     !8, 3
         45      > JMPZ_EX                                          ~31     ~31, ->48
         46    >   IS_NOT_IDENTICAL                                 ~32     !8, 5
         47        BOOL                                             ~31     ~32
         48    > > JMPZ                                                     ~31, ->50
   32    49    > > JMP                                                      ->73
   35    50    >   INIT_FCALL_BY_NAME                                       'isAnAttractionClosed'
         51        SEND_VAR_EX                                              !5
         52        SEND_VAR_EX                                              !0
         53        DO_FCALL                                      0  $33     
         54        ASSIGN                                           ~34     !9, $33
         55        TYPE_CHECK                                  1018          ~34
         56      > JMPZ                                                     ~35, ->70
   36    57    >   CONCAT                                           ~36     !7, '%3A+'
         58        FETCH_DIM_R                                      ~37     !9, 2
         59        CONCAT                                           ~38     ~36, ~37
         60        CONCAT                                           ~39     ~38, '+gesloten.+'
         61        FETCH_DIM_R                                      ~40     !9, 3
         62      > JMPZ                                                     ~40, ->65
         63    >   QM_ASSIGN                                        ~41     'Nee'
         64      > JMP                                                      ->66
         65    >   QM_ASSIGN                                        ~41     'Liever+niet'
         66    >   CONCAT                                           ~42     ~39, ~41
         67        CONCAT                                           ~43     ~42, '%0A'
         68        ECHO                                                     ~43
   37    69      > JMP                                                      ->73
   41    70    >   CONCAT                                           ~44     !7, '%3A+Ja'
         71        CONCAT                                           ~45     ~44, '%0A'
         72        ECHO                                                     ~45
   26    73    >   PRE_INC                                                  !5
         74        PRE_INC                                                  !6
         75    >   IS_SMALLER_OR_EQUAL                                      !5, !4
         76      > JMPNZ                                                    ~48, ->25
   60    77    > > 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/2uHAB
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
-------------------------------------------------------------------------------------
   49     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   50     2      > FE_RESET_R                                       $5      !1, ->30
          3    > > FE_FETCH_R                                               $5, !2, ->30
   51     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
   52    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
   54    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
   55    27    >   FE_FREE                                                  $5
         28      > RETURN                                                   !2
   50    29    > > JMP                                                      ->3
         30    >   FE_FREE                                                  $5
   59    31      > RETURN                                                   <false>
   60    32*     > RETURN                                                   null

End of function isanattractionclosed

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.85 ms | 1404 KiB | 19 Q