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; }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

preferences:
145.27 ms | 402 KiB | 188 Q