3v4l.org

run code in 300+ PHP versions simultaneously
<?php function nearest(array $arr, $needle) { $closest = current($arr); foreach ($arr as $val) { if ($val === $needle) { return $val; // found it :) } if ($val > $closest && $val < $needle) { // we found something closer and less than the needle, so use it $closest = $val; } } // we've reached the end, so return the closest solution return $closest; } $array = array(2012, 2013, 2014, 2015); $needle = 2000; print nearest($array, $needle);

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.00918.46
8.3.50.0090.01421.98
8.3.40.0180.00018.77
8.3.30.0080.00518.93
8.3.20.0040.00420.21
8.3.10.0050.00322.04
8.3.00.0100.00322.32
8.2.180.0150.00416.36
8.2.170.0090.00622.96
8.2.160.0100.00320.85
8.2.150.0000.00824.18
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0040.00419.36
8.2.110.0030.00622.10
8.2.100.0120.00019.54
8.2.90.0000.00819.21
8.2.80.0000.00817.97
8.2.70.0060.00317.38
8.2.60.0000.00817.80
8.2.50.0030.00518.07
8.2.40.0000.00818.16
8.2.30.0020.00517.93
8.2.20.0000.00717.76
8.2.10.0080.00019.53
8.2.00.0040.00417.79
8.1.280.0070.01025.92
8.1.270.0050.00322.10
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00423.81
8.1.230.0030.00719.04
8.1.220.0000.00817.79
8.1.210.0040.00418.77
8.1.200.0090.00017.23
8.1.190.0040.00417.43
8.1.180.0080.00018.61
8.1.170.0050.00318.59
8.1.160.0070.00021.98
8.1.150.0000.00718.51
8.1.140.0000.00817.45
8.1.130.0030.00317.66
8.1.120.0050.00217.41
8.1.110.0040.00417.45
8.1.100.0040.00417.40
8.1.90.0000.00717.42
8.1.80.0030.00517.36
8.1.70.0000.00717.36
8.1.60.0090.00017.57
8.1.50.0030.00517.48
8.1.40.0000.00817.50
8.1.30.0040.00417.55
8.1.20.0000.00917.70
8.1.10.0000.00917.52
8.1.00.0080.00017.33
8.0.300.0070.00018.77
8.0.290.0040.00417.05
8.0.280.0000.00818.43
8.0.270.0000.00817.34
8.0.260.0030.00316.77
8.0.250.0000.00616.97
8.0.240.0040.00416.87
8.0.230.0030.00316.95
8.0.220.0000.00716.91
8.0.210.0000.00716.79
8.0.200.0030.00516.91
8.0.190.0030.00616.92
8.0.180.0070.00016.80
8.0.170.0040.00416.75
8.0.160.0000.00716.91
8.0.150.0030.00716.82
8.0.140.0000.00816.87
8.0.130.0000.00513.27
8.0.120.0040.00416.75
8.0.110.0000.00916.87
8.0.100.0050.00216.77
8.0.90.0030.00516.68
8.0.80.0060.01516.89
8.0.70.0040.00416.95
8.0.60.0000.00816.84
8.0.50.0040.00416.91
8.0.30.0100.01017.03
8.0.20.0100.01017.40
8.0.10.0000.00717.03
8.0.00.0100.01116.70
7.4.330.0020.00215.14
7.4.320.0030.00316.61
7.4.300.0000.00616.51
7.4.290.0000.00716.51
7.4.280.0030.00316.63
7.4.270.0000.00816.58
7.4.260.0030.00316.48
7.4.250.0000.00716.57
7.4.240.0020.00516.42
7.4.230.0040.00416.63
7.4.220.0060.01916.52
7.4.210.0110.00516.53
7.4.200.0070.00016.63
7.4.190.0000.00716.66
7.4.160.0140.00616.44
7.4.150.0090.00917.40
7.4.140.0210.00317.86
7.4.130.0090.00916.44
7.4.120.0110.00616.45
7.4.110.0170.00716.41
7.4.100.0090.00816.62
7.4.90.0060.01216.45
7.4.80.0060.01619.39
7.4.70.0030.01316.49
7.4.60.0110.00416.57
7.4.50.0040.00416.36
7.4.40.0090.00622.77
7.4.30.0100.00616.61
7.4.00.0100.00614.86
7.3.330.0000.00513.26
7.3.320.0030.00313.39
7.3.310.0000.00716.34
7.3.300.0000.00716.28
7.3.290.0070.00716.27
7.3.280.0100.00716.40
7.3.270.0070.01017.40
7.3.260.0150.00316.49
7.3.250.0130.00316.49
7.3.240.0160.00616.54
7.3.230.0120.00616.63
7.3.210.0140.00716.40
7.3.200.0060.01019.39
7.3.190.0110.01116.44
7.3.180.0090.00616.45
7.3.170.0060.01016.51
7.3.160.0070.01016.39
7.3.120.0030.00914.73
7.3.10.0110.00316.68
7.3.00.0110.00816.29
7.2.330.0130.00416.86
7.2.320.0090.01816.58
7.2.310.0090.00916.71
7.2.300.0060.01116.70
7.2.290.0120.00416.64
7.2.130.0080.00416.59
7.2.120.0130.00616.63
7.2.110.0100.00716.74
7.2.100.0030.00716.77
7.2.90.0140.00716.81
7.2.80.0000.01116.88
7.2.70.0100.01016.66
7.2.60.0120.00416.87
7.2.50.0140.00816.73
7.2.40.0170.01016.91
7.2.30.0080.01117.06
7.2.20.0100.01016.71
7.2.10.0090.00616.97
7.2.00.0020.01318.21
7.1.250.0080.00815.64
7.1.100.0040.01118.17
7.1.70.0040.00417.25
7.1.60.0150.01119.82
7.1.50.0070.01416.88
7.1.00.0030.07322.31
7.0.200.0090.00016.61
7.0.140.0000.07722.15
7.0.60.0170.07719.97
7.0.50.0070.04717.89
7.0.40.0130.08020.27
7.0.30.0270.07020.20
7.0.20.0230.07020.07
7.0.10.0170.07720.23
7.0.00.0070.07020.25
5.6.280.0000.07721.09
5.6.210.0000.06020.48
5.6.200.0030.04018.22
5.6.190.0130.04320.68
5.6.180.0470.05320.64
5.6.170.0230.07020.39
5.6.160.0130.03320.50
5.6.150.0070.08718.23
5.6.140.0030.04018.21
5.6.130.0070.05318.27
5.6.120.0100.07721.05
5.6.110.0100.07021.14
5.6.100.0070.05721.11
5.6.90.0100.07721.11
5.6.80.0130.07020.38
5.5.350.4030.03720.34
5.5.340.0070.06017.94
5.5.330.0100.08320.40
5.5.320.0300.08720.34
5.5.310.0300.05320.35
5.5.300.0000.04018.02
5.5.290.0030.08718.02
5.5.280.0000.05720.66
5.5.270.0170.08320.86
5.5.260.0130.08020.84
5.5.250.0130.03320.59
5.5.240.0230.07020.04
5.4.450.0230.07319.31
5.4.440.0270.07319.45
5.4.430.0400.03719.48
5.4.420.0170.06719.47
5.4.410.0370.06019.14
5.4.400.0300.04019.14
5.4.390.0300.06018.86
5.4.380.0200.07019.31
5.4.370.0200.07719.32
5.4.360.0170.05018.88
5.4.350.0200.06018.98
5.4.340.0230.07319.23
5.4.320.0230.06318.86
5.4.310.0430.04019.21
5.4.300.0170.04018.88
5.4.290.0200.03319.24
5.4.280.0270.07018.98
5.4.270.0200.04719.19
5.4.260.0130.04319.24
5.4.250.0400.05318.94
5.4.240.0070.06719.05
5.4.230.0070.06019.21
5.4.220.0070.06319.15
5.4.210.0030.07019.13
5.4.200.0030.06319.15
5.4.190.0030.07319.08
5.4.180.0030.07319.09
5.4.170.0070.06318.93
5.4.160.0070.04319.11
5.4.150.0070.07719.07
5.4.140.0000.07016.29
5.4.130.0030.07016.38
5.4.120.0000.05316.46
5.4.110.0070.07316.45
5.4.100.0100.07016.56
5.4.90.0070.06716.56
5.4.80.0030.05316.46
5.4.70.0070.06716.26
5.4.60.0070.07316.45
5.4.50.0100.06316.26
5.4.40.0100.06316.52
5.4.30.0000.07716.42
5.4.20.0070.06716.57
5.4.10.0070.07316.48
5.4.00.0100.06315.73
5.3.290.0200.06714.73
5.3.280.0400.04714.52
5.3.270.0030.04714.68
5.3.260.0030.08014.76
5.3.250.0070.07314.51
5.3.240.0030.05314.61
5.3.230.0000.08014.49
5.3.220.0030.07314.49
5.3.210.0070.07014.54
5.3.200.0030.07714.48
5.3.190.0000.06714.53
5.3.180.0030.07314.72
5.3.170.0030.07714.72
5.3.160.0000.07314.68
5.3.150.0000.05314.56
5.3.140.0000.07314.67
5.3.130.0230.04314.66
5.3.120.0030.07714.64
5.3.110.0070.07714.66
5.3.100.0070.06314.06
5.3.90.0030.04713.99
5.3.80.0030.07013.99
5.3.70.0070.06714.23
5.3.60.0000.07714.01
5.3.50.0030.07013.93
5.3.40.0100.06314.11
5.3.30.0030.05713.93
5.3.20.0030.06313.59
5.3.10.0000.05013.88
5.3.00.0070.05313.79
5.2.170.0070.03712.59
5.2.160.0030.03712.59
5.2.150.0030.06012.59
5.2.140.0000.04312.59
5.2.130.0000.05012.59
5.2.120.0000.03712.59
5.2.110.0030.05012.59
5.2.100.0070.06012.59
5.2.90.0070.04012.59
5.2.80.0000.06712.59
5.2.70.0100.03712.59
5.2.60.0030.06312.59
5.2.50.0070.04712.59
5.2.40.0070.03312.59
5.2.30.0000.03312.59
5.2.20.0070.03012.59
5.2.10.0000.05312.59
5.2.00.0030.04312.59
5.1.60.0030.05012.59
5.1.50.0030.04012.59
5.1.40.0000.04012.59
5.1.30.0000.05712.59
5.1.20.0000.06012.59
5.1.10.0000.06012.59
5.1.00.0030.05712.59
5.0.50.0030.03712.59
5.0.40.0000.05012.59
5.0.30.0000.06712.59
5.0.20.0070.04012.59
5.0.10.0030.02312.59
5.0.00.0030.04012.59
4.4.90.0030.03312.59
4.4.80.0030.03312.59
4.4.70.0000.02712.59
4.4.60.0070.03312.59
4.4.50.0000.03312.59
4.4.40.0000.03312.59
4.4.30.0070.01712.59
4.4.20.0030.02712.59
4.4.10.0000.03712.59
4.4.00.0000.05312.59
4.3.110.0030.03312.59
4.3.100.0030.03012.59
4.3.90.0100.02712.59
4.3.80.0030.04312.59
4.3.70.0000.02312.59
4.3.60.0000.02012.59
4.3.50.0000.01712.59
4.3.40.0000.02712.59
4.3.30.0030.02712.59
4.3.20.0000.03712.59
4.3.10.0000.03712.59
4.3.00.0030.01712.59

preferences:
45.9 ms | 401 KiB | 5 Q