3v4l.org

run code in 300+ PHP versions simultaneously
<?php $times = array( 'mon' => '6:00 PM - 1:00 AM', 'tue' => '6:00 PM - 1:00 AM', 'wed' => '6:00 PM - 1:00 AM', 'thu' => '6:00 PM - 1:00 AM', 'fri' => '6:00 PM - 1:00 AM', 'sat' => '6:00 PM - 2:00 AM', 'sun' => '6:00 PM - 2:00 AM' ); function compileHours($times, $timestamp) { $times = $times[strtolower(date('D',$timestamp))]; if(!strpos($times, '-')) return array(); $hours = explode(",", $times); $hours = array_map('explode', array_pad(array(),count($hours),'-'), $hours); $hours = array_map('array_map', array_pad(array(),count($hours),'strtotime'), $hours, array_pad(array(),count($hours),array_pad(array(),2,$timestamp))); end($hours); if ($hours[key($hours)][0] > $hours[key($hours)][1]) $hours[key($hours)][1] = strtotime('+1 day', $hours[key($hours)][1]); return $hours; } function isOpen($now, $times) { $open = 0; // time until closing in seconds or 0 if closed // merge opening hours of today and the day before $hours = array_merge(compileHours($times, strtotime('yesterday',$now)),compileHours($times, $now)); foreach ($hours as $h) { if ($now >= $h[0] and $now < $h[1]) { $open = $h[1] - $now; return $open; } } return $open; } $now = strtotime('now'); $open = isOpen($now, $times); if ($open == 0) { echo "Is closed"; } else { echo "Is open; } ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.270.0130.05019.15
5.4.260.0100.07019.15
5.4.250.0000.06318.88
5.4.240.0100.05019.07
5.4.230.0100.05718.92
5.4.220.0100.06018.95
5.4.210.0200.04018.84
5.4.200.0130.05719.00
5.4.190.0000.06019.23
5.4.180.0200.04319.23
5.4.170.0100.07319.23
5.4.160.0130.05319.13
5.4.150.0230.06019.13
5.4.140.0170.04716.39
5.4.130.0100.06016.54
5.4.120.0200.04016.70
5.4.110.0000.06316.74
5.4.100.0000.06016.48
5.4.90.0030.05316.70
5.4.80.0170.04716.53
5.4.70.0130.07316.53
5.4.60.0100.04716.63
5.4.50.0070.06716.64
5.4.40.0170.04716.72
5.4.30.0200.03716.50
5.4.20.0030.05316.64
5.4.10.0130.04716.35
5.4.00.0100.06715.92
5.3.280.0200.06014.92
5.3.270.0070.06014.75
5.3.260.0230.06314.68
5.3.250.0100.05014.69
5.3.240.0130.05014.92
5.3.230.0170.06014.88
5.3.220.0170.04314.81
5.3.210.0000.06014.86
5.3.200.0070.05314.87
5.3.190.0030.06014.65
5.3.180.0070.06714.58
5.3.170.0100.05014.86
5.3.160.0100.04714.66
5.3.150.0170.06014.89
5.3.140.0130.04314.71
5.3.130.0100.05714.45
5.3.120.0030.07314.59
5.3.110.0100.05014.69
5.3.100.0070.05014.11
5.3.90.0100.04714.09
5.3.80.0100.04714.26
5.3.70.0100.05014.10
5.3.60.0130.04314.31
5.3.50.0100.06713.85
5.3.40.0100.05714.16
5.3.30.0070.05013.95
5.3.20.0100.04313.94
5.3.10.0170.04013.89
5.3.00.0030.05713.87
5.2.170.0130.05311.45
5.2.160.0100.04311.07
5.2.150.0130.03311.46
5.2.140.0030.04711.29
5.2.130.0100.05011.42
5.2.120.0070.03711.18
5.2.110.0100.04011.31
5.2.100.0100.03711.12
5.2.90.0100.04311.12
5.2.80.0070.05311.16
5.2.70.0070.04011.33
5.2.60.0030.05311.07
5.2.50.0030.04311.35
5.2.40.0000.04311.20
5.2.30.0130.03311.20
5.2.20.0000.05011.10
5.2.10.0130.03311.00
5.2.00.0070.05310.92
5.1.60.0070.03310.27
5.1.50.0000.04310.27
5.1.40.0030.04310.27
5.1.30.0130.04010.54
5.1.20.0130.03010.57
5.1.10.0070.03310.39
5.1.00.0130.02710.36
5.0.50.0100.03010.27
5.0.40.0130.02710.27
5.0.30.0070.04010.27
5.0.20.0000.04010.27
5.0.10.0030.03010.27
5.0.00.0100.04310.27
4.4.90.0000.02710.27
4.4.80.0070.02710.27
4.4.70.0000.02710.27
4.4.60.0000.02310.27
4.4.50.0000.02310.27
4.4.40.0030.03310.27
4.4.30.0000.02710.27
4.4.20.0070.02310.27
4.4.10.0030.03010.27
4.4.00.0070.03010.27
4.3.110.0000.02710.27
4.3.100.0000.02710.27
4.3.90.0000.03310.27
4.3.80.0030.03010.27
4.3.70.0070.02010.27
4.3.60.0000.03010.27
4.3.50.0070.02010.27
4.3.40.0100.04010.27
4.3.30.0070.02010.27
4.3.20.0070.02310.27
4.3.10.0000.02310.27
4.3.00.0100.0235.83

preferences:
140.26 ms | 1394 KiB | 7 Q