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 ) ); $amount = 113; $result_id = null; $take_next = false; foreach ($prices as $item) { if ($item['price'] < $amount) { $take_next = true; } elseif ($item['price'] == $amount){ $result_id = $item['id']; break; } else { if ($take_next){ $result_id = $item['id']; } break; } } echo "Closest ID: $result_id";

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.0120.01019.78
8.4.150.0010.00114.05
8.4.140.0140.00617.71
8.4.130.0110.00919.40
8.4.120.0060.00220.53
8.4.110.0100.01022.57
8.4.100.0110.00918.83
8.4.90.0100.01018.83
8.4.80.0090.01120.41
8.4.70.0080.00717.80
8.4.60.0120.00918.79
8.4.50.0090.01120.33
8.4.40.0090.00017.59
8.4.30.0090.00918.61
8.4.20.0100.00717.88
8.4.10.0060.00323.95
8.3.280.0090.01218.27
8.3.270.0100.00916.73
8.3.260.0100.01016.73
8.3.250.0120.00718.86
8.3.240.0100.01018.83
8.3.230.0130.00616.80
8.3.220.0120.00619.11
8.3.210.0050.00318.60
8.3.200.0070.00116.73
8.3.190.0130.00718.91
8.3.180.0110.00816.48
8.3.170.0140.00320.66
8.3.160.0040.01517.39
8.3.150.0110.00719.00
8.3.140.0120.00618.88
8.3.130.0110.00718.36
8.3.120.0060.00320.80
8.3.110.0080.00020.94
8.3.100.0060.00318.55
8.3.90.0040.00426.77
8.3.80.0070.00418.55
8.3.70.0140.00418.43
8.3.60.0030.01716.63
8.3.50.0140.00016.61
8.3.40.0030.01021.97
8.3.30.0070.00718.49
8.3.20.0070.00024.18
8.3.10.0050.00324.66
8.3.00.0080.00026.16
8.2.290.0070.01320.63
8.2.280.0080.00218.57
8.2.270.0150.00619.00
8.2.260.0110.00420.42
8.2.250.0040.00416.50
8.2.240.0030.00616.94
8.2.230.0030.00622.58
8.2.220.0070.00324.06
8.2.210.0070.01126.77
8.2.200.0000.00918.18
8.2.190.0000.01516.58
8.2.180.0070.00716.75
8.2.170.0150.00619.09
8.2.160.0070.00722.96
8.2.150.0070.00025.66
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0040.00426.16
8.2.110.0040.00420.53
8.2.100.0030.01017.78
8.2.90.0050.00317.75
8.2.80.0060.00318.91
8.2.70.0050.00517.75
8.2.60.0050.00317.50
8.2.50.0000.01117.63
8.2.40.0140.00317.74
8.2.30.0100.00617.72
8.2.20.0070.01017.72
8.2.10.0140.00317.72
8.2.00.0090.00717.72
8.1.330.0060.00422.12
8.1.320.0100.00816.13
8.1.310.0040.00416.70
8.1.300.0000.00918.09
8.1.290.0030.00730.84
8.1.280.0040.01625.92
8.1.270.0040.00422.14
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0070.00421.83
8.1.230.0060.00622.81
8.1.220.0000.00817.79
8.1.210.0030.00618.77
8.1.200.0060.00317.35
8.1.190.0000.00917.23
8.1.180.0050.00518.10
8.1.170.0120.00417.72
8.1.160.0100.00717.72
8.1.150.0110.00517.72
8.1.140.0110.00617.72
8.1.130.0150.00217.72
8.1.120.0130.00417.72
8.1.110.0150.00217.72
8.1.100.0130.00317.72
8.1.90.0110.00517.72
8.1.80.0150.00317.72
8.1.70.0110.00617.72
8.1.60.0160.00317.72
8.1.50.0100.00717.72
8.1.40.0140.00417.72
8.1.30.0100.00917.72
8.1.20.0120.00617.72
8.1.10.0120.00617.72
8.1.00.0150.00317.72
8.0.300.0040.00418.77
8.0.290.0000.00716.75
8.0.280.0110.00517.72
8.0.270.0090.00817.72
8.0.260.0130.00417.72
8.0.250.0100.00617.72
8.0.240.0150.00117.72
8.0.230.0090.00717.72
8.0.220.0160.00017.72
8.0.210.0110.00517.72
8.0.200.0170.00017.72
8.0.190.0140.00217.72
8.0.180.0120.00417.72
8.0.170.0110.00517.72
8.0.160.0130.00317.72
8.0.150.0110.00717.72
8.0.140.0030.01317.72
8.0.130.0110.00517.72
8.0.120.0160.00217.72
8.0.110.0140.00217.72
8.0.100.0130.00317.72
8.0.90.0150.00217.72
8.0.80.0150.00117.72
8.0.70.0080.01017.72
8.0.60.0080.00817.72
8.0.50.0120.00417.72
8.0.30.0090.00717.72
8.0.20.0090.00717.72
8.0.10.0110.00617.72

preferences:
32.24 ms | 403 KiB | 5 Q