3v4l.org

run code in 300+ PHP versions simultaneously
<?php function setting($v) { $db = [ 'opening_time_Sunday' => '10:30', 'closing_time_Sunday' => '00:00', 'opening_time_Monday' => '09:30', 'closing_time_Monday' => '01:30', 'opening_time_Tuesday' => '09:30', 'closing_time_Tuesday' => '01:30', 'opening_time_Wednesday' => '09:30', 'closing_time_Wednesday' => '01:30', 'opening_time_Thursday' => '09:30', 'closing_time_Thursday' => '01:30', 'opening_time_Friday' => '09:30', 'closing_time_Friday' => '23:00', 'opening_time_Saturday' => '10:30', 'closing_time_Saturday' => '00:00', ]; return $db[$v]; } function Today($dateString) { $currentDate = new \DateTimeImmutable($dateString); if (in_array($currentDate->format('N'), [2, 3, 4, 5])) { //check current time is not beyond the threshold //Monday = 1 and Sunday = 7 | Thursday = 4 $closedDate = $currentDate->setTime(1, 30, 00); if ($currentDate < $closedDate) { //change the date to display to day prior $currentDate = $currentDate->sub(new \DateInterval('P1D')); } } $today = $currentDate->format('l'); $start = setting('opening_time_' . $today); // Select value from settings table $end = setting('closing_time_' . $today); // Select value from settings table return $today . ': ' . $start . " - " . $end; } $dates = []; for ($i=0;$i<7;$i++) { $date = \date_create('2018-10-08'); if ($i > 0) { $date->modify('+' . $i . ' day'); } $dates[$date->format('l')] = [ '00:15' => Today($date->setTime(0, 15)->format('Y-m-d H:i:s')), '23:00' => Today($date->setTime(23, 0, 0)->format('Y-m-d H:i:s')) ]; } echo "Day \t|\t00:15:00\t\t\t|\t23:00:00\n"; foreach($dates as $day => $times) { echo "$day \t|\t{$times['00:15']} \t|\t{$times['23:00']}\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
Day | 00:15:00 | 23:00:00 Monday | Monday: 09:30 - 01:30 | Monday: 09:30 - 01:30 Tuesday | Monday: 09:30 - 01:30 | Tuesday: 09:30 - 01:30 Wednesday | Tuesday: 09:30 - 01:30 | Wednesday: 09:30 - 01:30 Thursday | Wednesday: 09:30 - 01:30 | Thursday: 09:30 - 01:30 Friday | Thursday: 09:30 - 01:30 | Friday: 09:30 - 23:00 Saturday | Saturday: 10:30 - 00:00 | Saturday: 10:30 - 00:00 Sunday | Sunday: 10:30 - 00:00 | Sunday: 10:30 - 00: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:
23.76 ms | 406 KiB | 5 Q