3v4l.org

run code in 300+ PHP versions simultaneously
<?php $vouchers = array( 1 => 100, 3 => 150, 5 => 100 ); $discounts = array(); $orders = array(50, 100, 200, 300, 500, 1000); foreach ($orders as $order) { $vouchers2 = $vouchers; foreach ($vouchers2 as $id => $voucher) { $discounts[$order][$id] = 0; } $remainingValue = $order; $voucher = array_pop($vouchers2); if ($voucher === null) { echo 'exiting for order '. $order . PHP_EOL; continue; } echo "order: " . $order . PHP_EOL; echo "voucher : " . $voucher . PHP_EOL; while($remainingValue > 0 && $voucher !== null) { $value = min ($remainingValue, $voucher); $discounts[$order][$id] = $value; $voucher = array_pop($vouchers2); $remainingValue -= $value; } } 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.0120.00916.50
8.3.50.0190.00618.05
8.3.40.0150.00018.77
8.3.30.0040.01119.17
8.3.20.0040.00420.33
8.3.10.0050.00321.70
8.3.00.0000.00819.02
8.2.180.0150.00316.34
8.2.170.0110.00418.82
8.2.160.0100.01022.96
8.2.150.0040.00424.18
8.2.140.0130.00324.66
8.2.130.0140.00026.16
8.2.120.0090.00019.61
8.2.110.0090.00022.43
8.2.100.0070.00618.22
8.2.90.0040.00419.26
8.2.80.0060.00317.97
8.2.70.0060.00317.63
8.2.60.0090.00018.04
8.2.50.0040.00418.07
8.2.40.0060.00320.07
8.2.30.0000.00718.05
8.2.20.0040.00417.66
8.2.10.0030.00518.05
8.2.00.0000.00917.73
8.1.280.0140.00725.92
8.1.270.0060.00318.91
8.1.260.0060.00326.35
8.1.250.0060.00328.09
8.1.240.0090.00022.02
8.1.230.0110.00019.09
8.1.220.0000.00717.76
8.1.210.0000.00818.77
8.1.200.0120.00417.25
8.1.190.0080.00017.23
8.1.180.0080.00018.10
8.1.170.0050.00318.66
8.1.160.0070.00021.93
8.1.150.0000.00718.80
8.1.140.0040.00419.16
8.1.130.0030.00317.78
8.1.120.0000.00717.37
8.1.110.0000.00817.43
8.1.100.0080.00017.46
8.1.90.0000.00717.49
8.1.80.0070.00017.51
8.1.70.0030.00517.35
8.1.60.0070.00417.61
8.1.50.0030.00617.45
8.1.40.0050.00217.48
8.1.30.0000.00917.57
8.1.20.0040.00417.62
8.1.10.0000.00817.54
8.1.00.0020.00517.42
8.0.300.0070.00018.77
8.0.290.0030.00616.63
8.0.280.0030.00318.45
8.0.270.0000.00717.18
8.0.260.0030.00317.30
8.0.250.0030.00316.96
8.0.240.0080.00016.85
8.0.230.0030.00317.00
8.0.220.0000.00716.87
8.0.210.0070.00016.87
8.0.200.0000.00616.93
8.0.190.0050.00216.92
8.0.180.0030.00616.93
8.0.170.0040.00416.88
8.0.160.0030.00316.94
8.0.150.0040.00416.79
8.0.140.0040.00416.92
8.0.130.0000.00613.39
8.0.120.0000.00816.79
8.0.110.0040.00416.80
8.0.100.0000.00816.80
8.0.90.0030.00516.79
8.0.80.0060.00916.83
8.0.70.0000.00816.69
8.0.60.0030.00516.81
8.0.50.0030.00516.75
8.0.30.0070.00717.09
8.0.20.0080.01217.40
8.0.10.0040.00417.08
8.0.00.0140.00516.69
7.4.330.0020.00215.03
7.4.320.0030.00316.66
7.4.300.0070.00016.61
7.4.290.0060.00316.59
7.4.280.0000.00816.49
7.4.270.0030.00316.50
7.4.260.0000.00816.58
7.4.250.0060.00316.53
7.4.240.0040.00316.59
7.4.230.0030.00316.63
7.4.220.0100.01316.65
7.4.210.0100.00616.41
7.4.200.0040.00416.59
7.4.160.0040.01116.64
7.4.150.0100.00717.40
7.4.140.0110.00717.86
7.4.130.0030.01516.47
7.4.120.0090.01116.63
7.4.110.0150.00816.46
7.4.100.0160.00316.59
7.4.90.0070.01016.34
7.4.80.0150.00619.39
7.4.70.0090.00616.65
7.4.60.0100.01016.55
7.4.50.0030.00516.54
7.4.40.0050.01916.44
7.4.30.0130.00716.66
7.4.00.0130.00015.07
7.3.330.0030.00313.06
7.3.320.0000.00613.09
7.3.310.0000.00816.23
7.3.300.0000.00616.32
7.3.290.0040.01316.30
7.3.280.0130.00416.36
7.3.270.0120.00417.40
7.3.260.0090.01216.37
7.3.250.0060.01216.30
7.3.240.0140.00316.66
7.3.230.0130.00916.46
7.3.210.0160.00316.50
7.3.200.0080.01619.39
7.3.190.0070.01016.44
7.3.180.0100.00616.32
7.3.170.0090.01216.30
7.3.160.0180.00616.38
7.2.330.0230.00816.73
7.2.320.0150.01016.72
7.2.310.0070.01416.79
7.2.300.0120.00616.55
7.2.290.0120.01216.82
7.2.00.0030.01019.52
7.1.200.0060.00615.75
7.1.100.0030.00918.22
7.1.70.0000.00817.08
7.1.60.0000.02319.46
7.1.50.0100.01617.11
7.1.00.0070.07322.46
7.0.200.0030.00616.86
7.0.140.0070.03022.15
7.0.60.0200.05720.06
7.0.50.0070.04017.84
7.0.40.0030.05720.20
7.0.30.0170.04320.01
7.0.20.0270.07020.33
7.0.10.0070.04319.99
7.0.00.0130.07020.00
5.6.280.0070.07020.89
5.6.210.0070.03720.63
5.6.200.0130.07318.08
5.6.190.0070.04320.35
5.6.180.0400.06320.63
5.6.170.0230.04720.40
5.6.160.0170.06720.49
5.6.150.0130.07318.18
5.6.140.0070.07718.20
5.6.130.0000.05318.20
5.6.120.0000.04321.14
5.6.110.0070.04321.02
5.6.100.0030.08021.02
5.6.90.0100.08020.99
5.6.80.0100.04020.43
5.5.350.0330.06320.41
5.5.340.0030.05018.02
5.5.330.0000.05320.43
5.5.320.0300.08720.29
5.5.310.0300.04020.29
5.5.300.0030.05318.02
5.5.290.0030.05017.95
5.5.280.0070.04720.73
5.5.270.0100.07720.89
5.5.260.0170.07320.76
5.5.250.0030.06720.50
5.5.240.0000.08320.16
5.4.450.0500.06719.63
5.4.440.0570.06019.58
5.4.430.0700.07019.47
5.4.420.0600.05319.48
5.4.410.0530.05019.32
5.4.400.0700.05019.30
5.4.390.0230.05318.70
5.4.380.0270.05018.76
5.4.370.0100.06318.70
5.4.360.0300.06318.70
5.4.350.0200.05718.69
5.4.340.0170.05718.75
5.4.320.0330.04318.46
5.4.310.0270.05018.58
5.4.300.0330.04318.50
5.4.290.0370.04018.69
5.4.280.0170.05718.70
5.4.270.0100.06018.52
5.4.260.0170.06318.48
5.4.250.0270.05718.49
5.4.240.0130.06318.50
5.4.230.0200.06718.64
5.4.220.0200.08318.54
5.4.210.0270.05718.59
5.4.200.0130.05716.71
5.4.190.0200.05718.69
5.4.180.0130.06318.61
5.4.170.0130.06718.51
5.4.160.0200.06018.39
5.4.150.0200.07018.59
5.4.140.0270.04716.18
5.4.130.0270.05716.20
5.4.120.0130.06016.27
5.4.110.0170.06016.17
5.4.100.0300.05016.23
5.4.90.0130.07016.37
5.4.80.0130.06716.34
5.4.70.0270.05716.30
5.4.60.0130.05716.15
5.4.50.0230.05316.11
5.4.40.0170.07716.23
5.4.30.0230.06716.02
5.4.20.0230.05316.20
5.4.10.0170.06016.20
5.4.00.0270.04315.72
5.3.290.0130.06014.67
5.3.280.0230.05014.52
5.3.270.0200.06014.51
5.3.260.0170.05714.61
5.3.250.0170.05714.60
5.3.240.0230.06314.61
5.3.230.0130.06014.50
5.3.220.0170.05714.47
5.3.210.0230.05314.58
5.3.200.0200.05314.51
5.3.190.0270.05014.49
5.3.180.0200.05014.61
5.3.170.0130.06014.54
5.3.160.0200.05014.66
5.3.150.0130.06314.50
5.3.140.0200.06314.54
5.3.130.0230.06014.63
5.3.120.0270.07014.66
5.3.110.0300.04314.49
5.3.100.0170.07314.03
5.3.90.0230.06314.12
5.3.80.0200.07013.97
5.3.70.0170.06013.97
5.3.60.0230.04314.11
5.3.50.0100.05713.91
5.3.40.0170.05313.92
5.3.30.0230.06713.82
5.3.20.0130.05713.69
5.3.10.0130.05713.58
5.3.00.0230.05013.64
5.2.170.0200.04311.13
5.2.160.0100.06711.12
5.2.150.0200.05711.19
5.2.140.0070.07011.19
5.2.130.0170.04011.02
5.2.120.0130.04311.08
5.2.110.0130.04311.02
5.2.100.0200.04011.16
5.2.90.0100.05711.10
5.2.80.0070.05011.11
5.2.70.0170.04011.06
5.2.60.0200.04311.09
5.2.50.0100.05011.07
5.2.40.0100.05011.05
5.2.30.0130.05710.95
5.2.20.0230.04710.92
5.2.10.0070.06010.99
5.2.00.0170.05310.84
5.1.60.0200.04010.03
5.1.50.0070.05710.07
5.1.40.0200.04310.02
5.1.30.0100.05310.44
5.1.20.0100.05710.54
5.1.10.0230.03310.10
5.1.00.0130.04010.11
5.0.50.0100.0278.66
5.0.40.0030.0338.54
5.0.30.0100.0478.36
5.0.20.0100.0308.20
5.0.10.0100.0308.20
5.0.00.0070.0508.31
4.4.90.0000.0305.91
4.4.80.0070.0375.95
4.4.70.0070.0305.92
4.4.60.0100.0376.00
4.4.50.0070.0305.90
4.4.40.0130.0375.95
4.4.30.0100.0275.93
4.4.20.0200.0206.02
4.4.10.0070.0275.98
4.4.00.0130.0375.99
4.3.110.0130.0235.86
4.3.100.0030.0275.89
4.3.90.0070.0205.83
4.3.80.0070.0335.86
4.3.70.0100.0205.83
4.3.60.0070.0205.82
4.3.50.0030.0275.93
4.3.40.0030.0405.77
4.3.30.0070.0274.78
4.3.20.0030.0334.78
4.3.10.0070.0204.78
4.3.00.0070.0279.38

preferences:
50.05 ms | 400 KiB | 5 Q