3v4l.org

run code in 300+ PHP versions simultaneously
<?php $vouchers = array( 1 => 100, 3 => 150, 5 => 100 ); $specials = array( 3 => true ); $discounts = array(); $orders = [50, 100, 200, 300, 500, 1000]; foreach ($orders as $order) { foreach ($vouchers as $voucher) { $discounts[$order][$voucher] = 0; } $remainingValue = $order; $voucher = array_pop($vouchers); if ($voucher === null) { continue; } while($remainingValue > 0 && $voucher !== null) { $value = min ($remainingValue, $voucher); $discounts[$order][$voucher] = $value; $vaucher = array_pop($vouchers); } } var_dump($discounts);

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.0101.99318.30
8.3.50.0071.99618.15
8.3.40.0101.99218.86
8.3.30.0071.99619.16
8.3.20.0031.99820.16
8.3.10.0101.99121.82
8.3.00.0031.99919.21
8.2.180.0071.99718.16
8.2.170.0131.99022.96
8.2.160.0171.98622.20
8.2.150.0002.00424.18
8.2.140.0031.99824.66
8.2.130.0032.00026.16
8.2.120.0032.00119.78
8.2.110.0002.00322.11
8.2.100.0131.99017.71
8.2.90.0031.99817.75
8.2.80.0071.99718.05
8.2.70.0002.00318.16
8.2.60.0032.00017.93
8.2.50.0031.99819.41
8.2.40.0072.00720.34
8.2.30.0031.99918.14
8.2.20.0032.00017.81
8.2.10.0002.00318.23
8.2.00.0032.00017.85
8.1.270.0002.00318.86
8.1.260.0032.00026.35
8.1.250.0002.00428.09
8.1.240.0101.99323.82
8.1.230.0071.99519.17
8.1.220.0032.00017.79
8.1.210.0002.00318.77
8.1.200.0002.00217.35
8.1.190.0032.00117.22
8.1.180.0031.99918.10
8.1.170.0031.99918.57
8.1.160.0031.99822.01
8.1.150.0032.00018.91
8.1.140.0031.99319.21
8.1.130.0002.00117.93
8.1.120.0002.00417.63
8.1.110.0031.99917.45
8.1.100.0061.99517.59
8.1.90.0002.00317.57
8.1.80.0031.99817.52
8.1.70.0031.99817.57
8.1.60.0071.99617.68
8.1.50.0131.99017.59
8.1.40.0101.99117.61
8.1.30.0002.00417.64
8.1.20.0002.00217.69
8.1.10.0071.99717.51
8.1.00.0032.00117.54
8.0.300.0071.99619.64
8.0.290.0002.00216.63
8.0.280.0031.99818.43
8.0.270.0101.99317.23
8.0.260.0031.99718.43
8.0.250.0031.99916.80
8.0.240.0002.00416.83
8.0.230.0002.00416.89
8.0.220.0071.99716.86
8.0.210.0032.00116.73
8.0.200.0071.99416.89
8.0.190.0071.99716.80
8.0.180.0032.00116.93
8.0.170.0002.00216.87
8.0.160.0002.00316.74
8.0.150.0031.99916.72
8.0.140.0071.99416.85
8.0.130.0071.99413.39
8.0.120.0031.99916.81
8.0.110.0002.00416.85
8.0.100.0131.98916.75
8.0.90.0071.99716.70
8.0.80.0131.98816.83
8.0.70.0032.00016.70
8.0.60.0071.99716.87
8.0.50.0002.00716.80
8.0.30.0181.95317.07
8.0.20.0181.98117.40
8.0.10.0002.00316.87
8.0.00.0271.97116.64
7.4.330.0031.99015.03
7.4.320.0002.00216.54
7.4.300.0002.00316.32
7.4.290.0071.99116.42
7.4.280.0032.00116.52
7.4.270.0031.99816.40
7.4.260.0102.00216.29
7.4.250.0101.99816.27
7.4.240.0022.00116.48
7.4.230.0031.99716.51
7.4.220.0161.98416.46
7.4.210.0161.98216.52
7.4.200.0031.99916.44
7.4.160.0171.97516.59
7.4.150.0131.98817.40
7.4.140.0052.00117.86
7.4.130.0131.99216.48
7.4.120.0081.99116.59
7.4.110.0102.44416.41
7.4.100.0202.45216.38
7.4.90.0072.44816.32
7.4.80.0102.44019.39
7.4.70.0132.46116.48
7.4.60.0162.45716.48
7.4.50.0032.49616.29
7.4.40.0352.23316.36
7.4.30.0232.41016.64
7.4.00.0002.49714.73
7.3.330.0031.99613.28
7.3.320.0031.99813.29
7.3.310.0031.99816.31
7.3.300.0031.99916.28
7.3.290.0091.99416.19
7.3.280.0131.98516.28
7.3.270.0101.99117.40
7.3.260.0191.98416.39
7.3.250.0101.99116.39
7.3.240.0102.00716.18
7.3.230.0401.45416.45
7.3.210.0072.46516.34
7.3.200.0202.44419.39
7.3.190.0132.44716.33
7.3.180.0132.45116.32
7.3.170.0062.46316.34
7.3.160.0132.46416.32
7.2.330.0132.46116.74
7.2.320.0262.43116.37
7.2.310.0102.47016.64
7.2.300.0162.46916.80
7.2.290.0162.43016.71
7.2.60.0072.49017.01
7.2.00.0072.49419.52
7.1.200.0102.47815.56
7.1.100.0102.49117.84
7.1.70.0102.49117.13
7.1.60.0032.49819.46
7.1.50.0032.49817.27
7.1.00.0032.49722.38
7.0.200.0202.47716.73
7.0.140.0032.49721.96
7.0.60.2272.27319.87
7.0.50.0002.50017.76
7.0.40.0032.48319.87
7.0.30.0302.45719.76
7.0.20.0202.48019.95
7.0.10.0102.49019.73
7.0.00.0102.47319.74
5.6.280.0032.49721.07
5.6.210.0102.49020.69
5.6.200.0002.50018.08
5.6.190.0102.49020.36
5.6.180.0272.46020.36
5.6.170.0202.48020.36
5.6.160.0132.48720.35
5.6.150.0072.49318.11
5.6.140.0002.50018.02
5.6.130.0072.49318.15
5.6.120.4532.04321.03
5.6.110.0132.48720.98
5.6.100.0072.49320.98
5.6.90.0102.49021.07
5.6.80.0072.49320.40
5.5.350.0372.46320.52
5.5.340.0002.50017.94
5.5.330.0172.47320.13
5.5.320.0072.49320.06
5.5.310.0172.48320.12
5.5.300.0072.49317.83
5.5.290.0132.48717.88
5.5.280.0032.49720.88
5.5.270.0102.49020.75
5.5.260.0072.49320.65
5.5.250.0032.49720.49
5.5.240.0072.49320.07
5.4.450.0072.49019.16
5.4.440.0202.47719.47
5.4.430.0202.47719.29
5.4.420.0032.49319.20
5.4.410.0132.48318.98
5.4.400.0032.49318.72
5.4.390.0272.46018.65
5.4.380.0272.47018.52
5.4.370.0202.46718.64
5.4.360.0172.45718.68
5.4.350.0302.37018.52
5.4.340.0232.43018.49
5.4.320.0232.44718.65
5.4.310.0302.46318.64
5.4.300.0302.42718.64
5.4.290.0072.41018.54
5.4.280.0202.41318.54
5.4.270.0272.38018.57
5.4.260.0332.46018.65
5.4.250.0302.47018.66
5.4.240.0172.44318.45
5.4.230.0202.39018.63
5.4.220.0372.31018.63
5.4.210.0202.29318.61
5.4.200.0372.39016.44
5.4.190.0072.41018.62
5.4.180.0202.39018.59
5.4.170.0232.37018.43
5.4.160.0172.37318.55
5.4.150.0172.43018.52
5.4.140.0232.41016.06
5.4.130.0232.44716.31
5.4.120.0302.46316.22
5.4.110.0172.46316.03
5.4.100.0302.39716.14
5.4.90.0102.48716.07
5.4.80.0072.49016.10
5.4.70.0232.45016.21
5.4.60.0172.46316.03
5.4.50.0372.44716.13
5.4.40.0132.42716.01
5.4.30.0372.30316.12
5.4.20.0202.40716.21
5.4.10.0372.36016.05

preferences:
69.06 ms | 400 KiB | 5 Q