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 "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.70.0120.00316.50
8.3.60.0130.00716.25
8.3.50.0150.00722.05
8.3.40.0160.00618.96
8.3.30.0190.00018.88
8.3.20.0080.00020.33
8.3.10.0040.00421.64
8.3.00.0040.01119.14
8.2.190.0110.00716.84
8.2.180.0120.00318.16
8.2.170.0030.01222.96
8.2.160.0090.00621.93
8.2.150.0030.00624.18
8.2.140.0030.00624.66
8.2.130.0040.00426.16
8.2.120.0090.00019.79
8.2.110.0100.01322.24
8.2.100.0130.00019.51
8.2.90.0000.00719.21
8.2.80.0030.00617.97
8.2.70.0000.00817.75
8.2.60.0080.00017.80
8.2.50.0050.00318.07
8.2.40.0080.00020.07
8.2.30.0050.00218.12
8.2.20.0030.00517.81
8.2.10.0040.00418.06
8.2.00.0000.00717.66
8.1.280.0090.00925.92
8.1.270.0090.00018.87
8.1.260.0080.00026.35
8.1.250.0000.00728.09
8.1.240.0100.00023.83
8.1.230.0070.00419.17
8.1.220.0040.00417.74
8.1.210.0060.00318.77
8.1.200.0070.00417.36
8.1.190.0050.00317.23
8.1.180.0080.00018.10
8.1.170.0050.00318.64
8.1.160.0040.00422.02
8.1.150.0050.00218.88
8.1.140.0050.00319.28
8.1.130.0030.00317.83
8.1.120.0000.00717.49
8.1.110.0070.00017.47
8.1.100.0070.00017.34
8.1.90.0080.00017.48
8.1.80.0050.00217.34
8.1.70.0070.00017.28
8.1.60.0000.01017.55
8.1.50.0060.00317.47
8.1.40.0040.00417.57
8.1.30.0040.00417.61
8.1.20.0060.00317.54
8.1.10.0040.00417.54
8.1.00.0040.00417.54
8.0.300.0020.00518.77
8.0.290.0040.00416.75
8.0.280.0070.00018.36
8.0.270.0070.00017.29
8.0.260.0030.00317.14
8.0.250.0000.00717.05
8.0.240.0040.00416.89
8.0.230.0040.00416.88
8.0.220.0020.00516.75
8.0.210.0040.00416.88
8.0.200.0040.00416.84
8.0.190.0040.00416.93
8.0.180.0100.00016.91
8.0.170.0030.00616.98
8.0.160.0040.00416.81
8.0.150.0100.00016.80
8.0.140.0030.00516.89
8.0.130.0030.00313.22
8.0.120.0070.00016.89
8.0.110.0080.00016.78
8.0.100.0000.00716.76
8.0.90.0030.00316.85
8.0.80.0090.01316.85
8.0.70.0000.00716.76
8.0.60.0000.00816.72
8.0.50.0040.00416.77
8.0.30.0090.01417.25
8.0.20.0080.01217.40
8.0.10.0000.00717.05
8.0.00.0120.00616.83
7.4.330.0000.00515.05
7.4.320.0000.00716.51
7.4.300.0030.00316.46
7.4.290.0070.00016.61
7.4.280.0060.00316.61
7.4.270.0030.00316.53
7.4.260.0070.00316.57
7.4.250.0060.00316.52
7.4.240.0020.00516.64
7.4.230.0070.00016.34
7.4.220.0130.01316.70
7.4.210.0040.01116.46
7.4.200.0070.00016.62
7.4.160.0100.00716.52
7.4.150.0190.00417.40
7.4.140.0150.00617.86
7.4.130.0060.01416.57
7.4.120.0090.00916.48
7.4.110.0070.01416.61
7.4.100.0090.01016.63
7.4.90.0120.00616.51
7.4.80.0090.01419.39
7.4.70.0110.00616.53
7.4.60.0060.01216.57
7.4.50.0050.00316.62
7.4.40.0130.00416.38
7.4.30.0130.00816.55
7.4.00.0030.01014.77
7.3.330.0050.00013.16
7.3.320.0030.00313.17
7.3.310.0030.00316.17
7.3.300.0030.00316.23
7.3.290.0070.00716.30
7.3.280.0090.00716.35
7.3.270.0060.01317.40
7.3.260.0060.01616.31
7.3.250.0130.00816.62
7.3.240.0140.00316.36
7.3.230.0130.00916.51
7.3.210.0170.00016.40
7.3.200.0080.00919.39
7.3.190.0060.01016.38
7.3.180.0120.00616.25
7.3.170.0120.00916.45
7.3.160.0140.01116.32
7.2.330.0080.01216.82
7.2.320.0110.00816.51
7.2.310.0000.01716.58
7.2.300.0140.00316.88
7.2.290.0040.01916.87
7.2.60.0100.01016.88
7.2.00.0100.00319.48
7.1.200.0030.00915.76
7.1.100.0060.00618.00
7.1.70.0130.00416.76
7.1.60.0060.00817.29
7.1.50.0140.01016.99
7.1.00.0070.07322.45
7.0.200.0000.01416.85
7.0.140.0000.07722.08
7.0.60.0030.07019.87
7.0.50.0070.03717.92
7.0.40.0170.07719.90
7.0.30.0070.05020.34
7.0.20.0270.04320.17
7.0.10.0130.05720.20
7.0.00.0100.08720.32
5.6.280.0000.07720.89
5.6.210.0100.03720.69
5.6.200.0030.04018.13
5.6.190.0100.04020.43
5.6.180.0470.06720.61
5.6.170.0270.04020.41
5.6.160.0000.06320.52
5.6.150.0030.08318.22
5.6.140.0100.06318.20
5.6.130.0130.03318.18
5.6.120.0070.04321.14
5.6.110.0130.07320.96
5.6.100.0070.08321.03
5.6.90.0100.06720.96
5.6.80.0100.06720.38
5.5.350.0330.07720.52
5.5.340.0100.08017.98
5.5.330.0000.04320.13
5.5.320.0000.06320.32
5.5.310.0330.04020.29
5.5.300.0100.04017.92
5.5.290.0230.06718.01
5.5.280.0100.08020.97
5.5.270.0030.04320.59
5.5.260.0030.06320.80
5.5.250.0030.08720.61
5.5.240.0070.07020.15
5.4.450.0100.05719.55
5.4.440.0570.05319.47
5.4.430.0630.05719.23
5.4.420.0730.04319.22
5.4.410.0770.05019.40
5.4.400.0600.05018.92
5.4.390.0230.06018.59
5.4.380.0200.06318.50
5.4.370.0370.05018.56
5.4.360.0270.06018.56
5.4.350.0170.08318.77
5.4.340.0400.06018.61
5.4.320.0300.05718.68
5.4.310.0300.06718.49
5.4.300.0200.06318.72
5.4.290.0130.06318.56
5.4.280.0230.05318.49
5.4.270.0200.06018.58
5.4.260.0200.05718.64
5.4.250.0470.06018.57
5.4.240.0430.06018.48
5.4.230.0170.06318.64
5.4.220.0170.05718.65
5.4.210.0170.05318.74
5.4.200.0170.05716.42
5.4.190.0230.04718.66
5.4.180.0270.05718.60
5.4.170.0270.05018.65
5.4.160.0200.05318.69
5.4.150.0270.06318.44
5.4.140.0230.04716.33
5.4.130.0270.05716.09
5.4.120.0200.05316.13
5.4.110.0270.06716.27
5.4.100.0130.06316.21
5.4.90.0270.05316.26
5.4.80.0100.07016.07
5.4.70.0130.06316.06
5.4.60.0200.06016.24
5.4.50.0270.04716.33
5.4.40.0200.05716.12
5.4.30.0100.05716.13
5.4.20.0070.06716.12
5.4.10.0230.04716.24
5.4.00.0200.05315.72
5.3.290.0170.06314.58
5.3.280.0200.06714.58
5.3.270.0100.07014.67
5.3.260.0230.05714.59
5.3.250.0230.05014.64
5.3.240.0170.05714.59
5.3.230.0200.06014.57
5.3.220.0200.05714.46
5.3.210.0130.07014.48
5.3.200.0230.05314.62
5.3.190.0300.05314.66
5.3.180.0070.06714.56
5.3.170.0170.07714.56
5.3.160.0170.05314.66
5.3.150.0300.04714.56
5.3.140.0070.06014.65
5.3.130.0270.04714.55
5.3.120.0330.05314.65
5.3.110.0270.06714.54
5.3.100.0230.05713.99
5.3.90.0270.04313.98
5.3.80.0170.05314.02
5.3.70.0130.05713.94
5.3.60.0270.05013.90
5.3.50.0200.05713.94
5.3.40.0230.05014.04
5.3.30.0130.06013.99
5.3.20.0200.04713.65
5.3.10.0200.04713.63
5.3.00.0100.06013.59
5.2.170.0170.04311.16
5.2.160.0070.05311.19
5.2.150.0130.04711.17
5.2.140.0300.04311.30
5.2.130.0270.03311.27
5.2.120.0170.04711.17
5.2.110.0130.05011.02
5.2.100.0100.05011.27
5.2.90.0270.03711.27
5.2.80.0170.04711.04
5.2.70.0100.05711.07
5.2.60.0230.05311.04
5.2.50.0230.05311.08
5.2.40.0070.05011.05
5.2.30.0130.06011.02
5.2.20.0130.04710.90
5.2.10.0200.03710.91
5.2.00.0200.05010.82
5.1.60.0100.04010.20
5.1.50.0170.03310.07
5.1.40.0170.03010.11
5.1.30.0130.04310.39
5.1.20.0130.04010.39
5.1.10.0130.03710.10
5.1.00.0130.05010.26
5.0.50.0100.0278.59
5.0.40.0130.0208.49
5.0.30.0070.0438.27
5.0.20.0030.0338.38
5.0.10.0130.0378.37
5.0.00.0100.0438.21
4.4.90.0130.0205.96
4.4.80.0130.0206.00
4.4.70.0070.0235.89
4.4.60.0070.0235.90
4.4.50.0030.0235.92
4.4.40.0100.0375.89
4.4.30.0070.0235.83
4.4.20.0070.0335.96
4.4.10.0130.0275.95
4.4.00.0030.0435.96
4.3.110.0030.0275.86
4.3.100.0100.0175.82
4.3.90.0030.0235.82
4.3.80.0030.0375.96
4.3.70.0030.0235.89
4.3.60.0030.0235.80
4.3.50.0070.0235.85
4.3.40.0130.0375.84
4.3.30.0070.0204.78
4.3.20.0030.0234.78
4.3.10.0030.0234.78
4.3.00.0100.0239.38

preferences:
29.67 ms | 401 KiB | 5 Q