3v4l.org

run code in 300+ PHP versions simultaneously
<?php $storeSchedule = [ 'Sun' => [['12:00' => '01:00', '10:00' => '12:00']], 'Mon' => [['09:00' => '12:00']], 'Tue' => [['09:00' => '12:00']], 'Wed' => [['09:00' => '12:00']], 'Thu' => [['09:00' => '12:00'], ['22:50' => '23:00']], 'Fri' => [['09:00' => '12:00']], 'Sat' => [['12:00' => '01:00', '09:00' => '12:00']] ]; $today = date("D"); $closed = Null; foreach($storeSchedule[$today] as $opentimes){ foreach($opentimes as $open => $close){ $now = time(); if($now > strtotime(date("Y-m-d" . $open)) && $now < strtotime(date("Y-m-d" . $close))){ echo "store open now"; $closed = false; }else if($now < strtotime(date("Y-m-d" . $open))){ echo "store will open at " . date("Y-m-d" . $open); $closed = false; }else{ // Store is closed if($closed !== false) $closed = true; } } } if($closed){ // Dump the next open time var_dump($storeSchedule[date("D",strtotime($today)+86400)]); }
Output for git.master, git.master_jit
array(1) { [0]=> array(2) { ["12:00"]=> string(5) "01:00" ["10:00"]=> string(5) "12:00" } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
79.96 ms | 405 KiB | 5 Q