3v4l.org

run code in 300+ PHP versions simultaneously
<?php $prices = array( array('id' => '28','price' =>100 ), array('id' => '29','price' =>105 ), array('id' => '30','price' =>110 ), array('id' => '31','price' =>115 ), array('id' => '32','price' =>120 ), array('id' => '33','price' =>125 ), array('id' => '34','price' =>130 ) ); function getNearestHighest($prices, $amount){ $resullt = null; $diff = PHP_INT_MAX; foreach($prices as $p){ if($p['price'] >= $amount){ if(abs($p['price'] - $amount) < $diff){ $result = $p; $diff = abs($p['price'] - $amount); } } } if(is_null($result)) throw new \Exception("No nearest highest amount exists!"); return $result; } try{ print_r(getNearestHighest($prices, 113)); }catch(\Exception $e){ // whatever you wish to do }

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.5.00.0130.00820.14
8.4.150.0030.00014.05
8.4.140.0130.00817.33
8.4.130.0090.00017.59
8.4.120.0100.01122.43
8.4.110.0070.00320.73
8.4.100.0050.00417.72
8.4.90.0060.00317.63
8.4.80.0110.00817.80
8.4.70.0070.00617.94
8.4.60.0160.00618.80
8.4.50.0140.00718.46
8.4.40.0060.00317.58
8.4.30.0150.00318.80
8.4.20.0110.01117.89
8.4.10.0070.01323.87
8.3.280.0100.00918.30
8.3.270.0130.00716.58
8.3.260.0120.00716.62
8.3.250.0100.00819.05
8.3.240.0090.01019.04
8.3.230.0100.00916.48
8.3.220.0050.00516.67
8.3.210.0090.01016.73
8.3.200.0060.00316.71
8.3.190.0080.01017.22
8.3.180.0120.00917.20
8.3.170.0110.00718.94
8.3.160.0000.01817.50
8.3.150.0130.00617.16
8.3.140.0030.00716.70
8.3.130.0130.00318.21
8.3.120.0050.00520.73
8.3.110.0060.00620.94
8.3.100.0030.00624.06
8.3.90.0000.00826.77
8.3.80.0030.00718.43
8.3.70.0090.00618.31
8.3.60.0110.00716.63
8.3.50.0110.00316.84
8.3.40.0080.00621.79
8.3.30.0070.00718.76
8.3.20.0040.00424.18
8.3.10.0040.00424.66
8.3.00.0080.00026.16
8.2.290.0100.00820.30
8.2.280.0080.01018.11
8.2.270.0120.00617.41
8.2.260.0110.00716.46
8.2.250.0120.00618.47
8.2.240.0120.00617.29
8.2.230.0000.00922.58
8.2.220.0050.00337.54
8.2.210.0030.00626.77
8.2.200.0120.00016.75
8.2.190.0140.00718.54
8.2.180.0090.00916.63
8.2.170.0140.00719.01
8.2.160.0140.00422.96
8.2.150.0080.00025.66
8.2.140.0050.00224.66
8.2.130.0030.00626.16
8.2.120.0050.00226.16
8.2.110.0100.00021.00
8.2.100.0080.00417.84
8.2.90.0090.00017.75
8.2.80.0000.00818.91
8.2.70.0090.00017.75
8.2.60.0000.00817.50
8.2.50.0040.00417.63
8.2.40.0090.00617.72
8.2.30.0030.00717.72
8.2.20.0160.00017.72
8.2.10.0120.00417.72
8.2.00.0100.00717.72
8.1.330.0130.00616.77
8.1.320.0110.00715.79
8.1.310.0080.00016.84
8.1.300.0100.01018.35
8.1.290.0030.00630.84
8.1.280.0070.01125.92
8.1.270.0050.00324.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00020.96
8.1.230.0040.00817.72
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0040.00417.35
8.1.190.0040.00717.25
8.1.180.0080.00018.10
8.1.170.0000.00917.72
8.1.160.0160.00017.72
8.1.150.0080.00817.72
8.1.140.0100.00617.72
8.1.130.0100.00717.72
8.1.120.0160.00017.72
8.1.110.0140.00217.72
8.1.100.0140.00217.72
8.1.90.0160.00017.72
8.1.80.0110.00517.72
8.1.70.0140.00417.72
8.1.60.0160.00017.72
8.1.50.0130.00417.72
8.1.40.0070.01117.72
8.1.30.0070.01417.72
8.1.20.0130.00417.72
8.1.10.0110.00617.72
8.1.00.0090.00917.72
8.0.300.0070.00018.77
8.0.290.0040.00416.75
8.0.280.0160.00017.72
8.0.270.0080.00817.72
8.0.260.0110.00617.72
8.0.250.0160.00017.72
8.0.240.0180.00017.72
8.0.230.0140.00317.72
8.0.220.0120.00517.72
8.0.210.0080.00817.72
8.0.200.0130.00317.72
8.0.190.0180.00317.72
8.0.180.0040.01317.72
8.0.170.0080.00817.72
8.0.160.0080.00817.72
8.0.150.0160.00017.72
8.0.140.0120.00317.72
8.0.130.0100.00517.72
8.0.120.0110.00517.72
8.0.110.0150.00017.72
8.0.100.0050.01117.72
8.0.90.0160.00017.72
8.0.80.0150.00017.72
8.0.70.0140.00317.72
8.0.60.0170.00017.72
8.0.50.0160.00017.72
8.0.30.0150.00617.72
8.0.20.0110.00517.72
8.0.10.0120.00417.72

preferences:
30.83 ms | 403 KiB | 5 Q