3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); date_default_timezone_set('America/New_York'); $day = strtolower(date('D')); $current_time = date('Hi'); $day = 'mon'; $current_time = '1630'; $liveshows = [ 'mon' => [ ['start' => '0600', 'end' => '0900', 'host' => 'Joe'], ['start' => '1300', 'end' => '1500', 'host' => 'Carol'], ['start' => '1500', 'end' => '1600', 'host' => 'Cortez'], ['start' => '1700', 'end' => '2100', 'host' => 'Boy George'], ], ]; if ($day === 'mon' && !empty($liveshows['mon'])) { $isIsOnAir = false; foreach ($liveshows['mon'] as $showtime) { if ($showtime['start'] <= $current_time && $current_time <= $showtime['end']) { $isIsOnAir = true; echo '<h3>', $showtime['host'], ' <span>is on air</span></h3>'; break; } } if (!$isIsOnAir) { echo '<h3>No live show is on</h3>'; foreach ($liveshows['mon'] as $showtime) { if ($current_time < $showtime['start']) { echo '<p>The next live show is at ', date('g:iA', strtotime($showtime['start'])), '</p>'; break; } } } }
Output for 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.19, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
<h3>No live show is on</h3><p>The next live show is at 5:00PM</p>
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 <h3>No live show is on</h3><p>The next live show is at 5:00PM</p>

preferences:
104.08 ms | 402 KiB | 154 Q