3v4l.org

run code in 300+ PHP versions simultaneously
<?php $times = array( 'mon' => '9:00 AM - 12:00 AM', 'tue' => '9:00 AM - 12:00 AM', 'wed' => '9:00 AM - 12:00 AM', 'thu' => '9:00 AM - 12:00 AM', 'fri' => '9:00 AM - 1:00 AM', 'sat' => '9:00 AM - 1:00 PM, 2:00 PM - 1:00 AM', '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; } echo isOpen();

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.3.60.0120.00316.88
8.3.50.0100.01018.18
8.3.40.0120.00318.98
8.3.30.0140.00318.63
8.3.20.0070.00020.33
8.3.10.0060.00323.64
8.3.00.0070.00319.50
8.2.180.0070.00716.88
8.2.170.0110.00322.96
8.2.160.0100.00320.39
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0000.00817.63
8.2.110.0050.00520.35
8.2.100.0080.00417.72
8.2.90.0040.00417.95
8.2.80.0000.00917.97
8.2.70.0000.00817.38
8.2.60.0090.00017.80
8.2.50.0030.00618.07
8.2.40.0000.00820.90
8.2.30.0000.00720.59
8.2.20.0030.00517.79
8.2.10.0080.00019.82
8.2.00.0000.00818.14
8.1.280.0140.00725.92
8.1.270.0040.00423.93
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0060.00322.09
8.1.230.0090.00320.96
8.1.220.0050.00317.77
8.1.210.0060.00318.77
8.1.200.0030.00717.35
8.1.190.0030.00517.23
8.1.180.0050.00318.10
8.1.170.0040.00420.37
8.1.160.0050.00222.04
8.1.150.0050.00218.76
8.1.140.0050.00319.45
8.1.130.0000.00817.67
8.1.120.0040.00417.45
8.1.110.0030.00417.42
8.1.100.0070.00017.43
8.1.90.0000.00717.46
8.1.80.0050.00317.40
8.1.70.0050.00317.40
8.1.60.0030.00617.50
8.1.50.0000.01017.51
8.1.40.0060.00317.56
8.1.30.0050.00317.54
8.1.20.0040.00417.59
8.1.10.0080.00017.65
8.1.00.0000.00717.39
8.0.300.0000.00720.04
8.0.290.0040.00416.63
8.0.280.0000.00718.37
8.0.270.0000.00817.22
8.0.260.0060.00017.18
8.0.250.0040.00416.96
8.0.240.0030.00616.99
8.0.230.0050.00316.97
8.0.220.0000.00816.91
8.0.210.0040.00416.81
8.0.200.0060.00016.98
8.0.190.0070.00016.93
8.0.180.0030.00616.88
8.0.170.0000.00816.98
8.0.160.0040.00416.96
8.0.150.0000.00816.93
8.0.140.0000.00716.93
8.0.130.0000.00613.23
8.0.120.0040.00416.85
8.0.110.0080.00016.95
8.0.100.0020.00516.93
8.0.90.0050.00316.81
8.0.80.0070.00816.87
8.0.70.0030.00516.91
8.0.60.0000.00716.76
8.0.50.0040.00416.86
8.0.30.0100.00917.04
8.0.20.0100.00917.40
8.0.10.0040.00417.02
8.0.00.0060.01116.85
7.4.330.0000.00515.08
7.4.320.0030.00316.57
7.4.300.0050.00316.61
7.4.290.0000.00816.53
7.4.280.0000.00816.54
7.4.270.0000.00716.44
7.4.260.0070.00016.50
7.4.250.0020.00516.54
7.4.240.0030.00316.55
7.4.230.0040.00416.63
7.4.220.0090.00916.45
7.4.210.0100.00316.66
7.4.200.0030.00316.71
7.4.160.0080.00816.61
7.4.150.0070.01017.40
7.4.140.0090.00817.86
7.4.130.0120.00516.58
7.4.120.0100.00816.46
7.4.110.0120.00916.76
7.4.100.0100.00716.68
7.4.90.0080.00816.69
7.4.80.0060.01119.39
7.4.70.0060.00916.36
7.4.60.0130.00316.55
7.4.50.0080.00016.61
7.4.40.0170.00716.45
7.4.30.0090.00916.46
7.4.00.0030.01014.77
7.3.330.0060.00013.14
7.3.320.0020.00213.27
7.3.310.0020.00516.22
7.3.300.0000.00716.34
7.3.290.0070.00816.32
7.3.280.0070.00816.34
7.3.270.0040.01317.40
7.3.260.0150.00316.48
7.3.250.0090.00916.43
7.3.240.0060.01416.35
7.3.230.0180.00616.52
7.3.210.0130.00316.34
7.3.200.0100.00616.32
7.3.190.0080.00816.36
7.3.180.0130.00916.43
7.3.170.0040.01216.27
7.3.160.0100.00616.41
7.2.330.0130.00716.67
7.2.320.0100.00716.26
7.2.310.0100.00716.45
7.2.300.0080.00916.58
7.2.290.0170.00016.45
7.2.60.0040.01116.89
7.2.00.0030.01019.18
7.1.200.0030.00615.56
7.1.100.0060.00617.85
7.1.70.0030.00617.01
7.1.60.0070.01819.13
7.1.50.0130.00716.83
7.1.00.0000.07722.31
7.0.200.0040.00715.18
7.0.100.0530.07719.95
7.0.90.0400.07720.00
7.0.80.0300.04719.95
7.0.70.0500.08020.14
7.0.60.0370.08719.91
7.0.50.0370.05720.33
7.0.40.0100.07720.18
7.0.30.0030.06320.10
7.0.20.0030.08020.09
7.0.10.0230.06720.05
7.0.00.0070.04320.00
5.6.280.0070.07021.08
5.6.250.0030.08720.61
5.6.240.0100.04320.77
5.6.230.0100.04720.68
5.6.220.0070.04020.50
5.6.210.0100.07320.48
5.6.200.0130.07721.11
5.6.190.0070.06021.09
5.6.180.0130.07321.03
5.6.170.0070.09021.05
5.6.160.0100.04021.05
5.6.150.0170.03321.02
5.6.140.0070.06720.95
5.6.130.0130.08321.02
5.6.120.0100.05721.02
5.6.110.0100.07721.03
5.6.100.0130.08021.02
5.6.90.0100.08321.11
5.6.80.0070.08020.45
5.6.70.0030.08320.44
5.6.60.0100.06020.41
5.6.50.0200.07020.34
5.6.40.0030.08320.39
5.6.30.0130.07320.55
5.6.20.0070.04320.45
5.6.10.0100.04020.32
5.6.00.0070.03720.36
5.5.380.0070.04720.39
5.5.370.0070.06720.46
5.5.360.0100.08720.36
5.5.350.0030.08720.41
5.5.340.0030.07720.75
5.5.330.0100.07020.85
5.5.320.0100.05320.84
5.5.310.0130.05320.89
5.5.300.0070.06320.85
5.5.290.0030.05320.90
5.5.280.0070.05020.87
5.5.270.0100.08720.87
5.5.260.0100.08320.94
5.5.250.0300.03020.62
5.5.240.0100.04320.28
5.5.230.0100.07720.02
5.5.220.0170.04720.19
5.5.210.0070.08020.31
5.5.200.0030.08320.29
5.5.190.0030.08020.11
5.5.180.0100.04320.28
5.5.160.0070.03720.14
5.5.150.0000.04320.21
5.5.140.0070.03720.14
5.5.130.0030.04020.14
5.5.120.0170.03020.05
5.5.110.0000.04320.25
5.5.100.0100.07720.04
5.5.90.0070.07319.95
5.5.80.0030.04019.99
5.5.70.0130.07720.16
5.5.60.0100.07319.92
5.5.50.0070.05020.07
5.5.40.0070.05320.02
5.5.30.0030.04020.11
5.5.20.0070.07320.08
5.5.10.0070.05020.09
5.5.00.0070.03719.98
5.4.450.0100.08019.38
5.4.440.0130.07719.37
5.4.430.0130.03719.54
5.4.420.0070.07319.53
5.4.410.0000.06019.36
5.4.400.0030.04019.09
5.4.390.0030.07018.85
5.4.380.0100.07019.18
5.4.370.0100.07019.03
5.4.360.0130.07318.95
5.4.350.0030.07019.12
5.4.340.0100.03319.18
5.4.320.0030.03719.21
5.4.310.0170.06019.03
5.4.300.0000.04019.09
5.4.290.0030.04019.12
5.4.280.0070.03719.17
5.4.270.0100.03719.18
5.4.260.0100.06018.84
5.4.250.0100.06319.02
5.4.240.0100.03318.89
5.4.230.0130.06318.84
5.4.220.0030.03719.12
5.4.210.0030.06719.09
5.4.200.0070.03318.86
5.4.190.0070.03018.84
5.4.180.0030.06718.86
5.4.170.0030.04019.20
5.4.160.0100.03719.18
5.4.150.0100.03018.85
5.4.140.0030.03716.37
5.4.130.0030.03716.41
5.4.120.0000.03716.41
5.4.110.0070.03716.32
5.4.100.0000.04016.55
5.4.90.0000.03716.38
5.4.80.0000.03716.43
5.4.70.0030.03016.51
5.4.60.0030.03316.37
5.4.50.0070.04716.50
5.4.40.0100.02716.45
5.4.30.0130.04016.52
5.4.20.0130.02016.51
5.4.10.0100.03316.45
5.4.00.0030.03715.80

preferences:
53.36 ms | 400 KiB | 5 Q