3v4l.org

run code in 300+ PHP versions simultaneously
<?php function open_closed_message() { date_default_timezone_set('America/Toronto'); $date = new DateTime; echo date("D m/d/y h:i:s ",time()); $times = array( 'mon' => '9:00 AM - 9:00 PM', 'tue' => '9:00 AM - 9:00 PM', 'wed' => '9:00 AM - 9:00 PM', 'thu' => '9:00 AM - 9:00 PM', 'fri' => '9:00 AM - 9:00 PM', 'sat' => '11:00 AM - 6:00 PM', 'sun' => 'closed' ); 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 = time(); $open = isOpen($now, $times); if ($open == 0) { echo "Closed - Sorry, we are not making deliveries."; } elseif ($open <= 1800) { $tomorrow = strtotime('tomorrow', $now); if (date('N', $tomorrow) == 7) { $tomorrow = strtotime('next monday', $now); } $day = strtolower(date('D', $tomorrow)); $tomorrow = date('l', $tomorrow); $opentime = preg_replace('/^(\d+:\d+ [AP]M).*/', '$1', $times[$day]); echo "Finishing up current orders. We re-open $tomorrow at $opentime"; } else { echo "Open - Yes, we are making deliveries."; } } open_closed_message();

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)
8.2.60.0090.00417.56
8.0.80.0060.01317.14
8.0.70.0080.01517.10
8.0.60.0110.01217.06
8.0.50.0120.01017.01
8.0.30.0180.00917.27
8.0.20.0110.01317.25
8.0.10.0180.00717.32
8.0.00.0170.00617.40
7.4.210.0110.01116.79
7.4.200.0090.01116.68
7.4.190.0130.00616.75
7.4.180.0070.01416.70
7.4.160.0140.00816.78
7.4.150.0170.00416.84
7.4.140.0140.00716.70
7.4.130.0170.00616.75
7.4.120.0170.00416.73
7.4.110.0150.00416.68
7.4.100.0170.00716.80
7.4.90.0120.00816.70
7.4.80.0140.01016.70
7.4.70.0140.00916.73
7.4.60.0110.01116.63
7.4.50.0120.01116.67
7.4.40.0130.00816.63
7.4.30.0100.01116.69
7.4.20.0120.01316.67
7.4.10.0170.00716.79
7.4.00.0110.01116.64
7.3.290.0060.01416.56
7.3.280.0100.01116.61
7.3.270.0150.00716.57
7.3.260.0130.00916.60
7.3.250.0200.00416.69
7.3.240.0140.00916.67
7.3.230.0170.00716.59
7.3.220.0160.01016.65
7.3.210.0110.01016.59
7.3.200.0120.00916.60
7.3.190.0130.01116.56
7.3.180.0160.00816.62
7.3.170.0110.01116.60
7.3.160.0190.00816.61
7.3.150.0150.00916.59
7.3.140.0150.01016.57
7.3.130.0160.00916.66
7.3.120.0130.01216.62
7.3.110.0130.01016.59
7.3.100.0140.00916.58
7.3.90.0150.00916.67
7.3.80.0160.00916.58
7.3.70.0140.00816.61
7.3.60.0130.00916.65
7.3.50.0130.01116.65
7.3.40.0150.00916.65
7.3.30.0170.00616.67
7.3.20.0160.01016.66
7.3.10.0150.00916.59
7.3.00.0130.01016.68
7.2.340.0200.00716.84
7.2.330.0140.00916.78
7.2.320.0140.01016.75
7.2.310.0160.01016.73
7.2.300.0160.00616.81
7.2.290.0120.00916.81
7.2.280.0180.00616.80
7.2.270.0130.01216.85
7.2.260.0170.00916.71
7.2.250.0190.00716.79
7.2.240.0140.01116.83
7.2.230.0180.00716.83
7.2.220.0140.01116.81
7.2.210.0150.00916.81
7.2.200.0110.01416.85
7.2.190.0140.01016.83
7.2.180.0140.01016.84
7.2.170.0130.01216.87
7.2.160.0150.00916.87
7.2.150.0180.01116.94
7.2.140.0140.01016.92
7.2.130.0190.00816.92
7.2.120.0180.00616.95
7.2.110.0140.01116.98
7.2.100.0170.01016.95
7.2.90.0160.00816.90
7.2.80.0120.01116.86
7.2.70.0150.00816.88
7.2.60.0140.01116.93
7.2.50.0160.00916.88
7.2.40.0160.01016.96
7.2.30.0160.00916.98
7.2.20.0160.00816.89
7.2.10.0160.01116.92
7.2.00.0160.00916.89

preferences:
43.53 ms | 401 KiB | 5 Q