3v4l.org

run code in 300+ PHP versions simultaneously
<?php $vouchers = array( 1 => 100, 3 => 150, 5 => 100 ); $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; $voucher = 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.0070.00716.63
8.3.50.0110.00722.04
8.3.40.0120.00318.79
8.3.30.0000.01419.21
8.3.20.0080.00020.38
8.3.10.0030.00521.76
8.3.00.0090.00019.11
8.2.180.0180.00416.88
8.2.170.0070.01422.96
8.2.160.0130.00722.25
8.2.150.0080.00024.18
8.2.140.0170.00024.66
8.2.130.0030.00526.16
8.2.120.0120.00619.90
8.2.110.0100.00022.20
8.2.100.0070.00417.84
8.2.90.0000.00817.63
8.2.80.0090.00017.97
8.2.70.0000.00817.93
8.2.60.0060.00317.93
8.2.50.0050.00319.39
8.2.40.0030.00620.47
8.2.30.0000.00818.08
8.2.20.0000.00817.79
8.2.10.0040.00418.12
8.2.00.0030.00617.63
8.1.280.0110.00425.92
8.1.270.0030.00719.00
8.1.260.0050.00526.35
8.1.250.0080.00028.09
8.1.240.0030.00623.91
8.1.230.0080.00420.95
8.1.220.0060.00317.74
8.1.210.0050.00518.77
8.1.200.0060.00317.37
8.1.190.0050.00317.25
8.1.180.0040.00418.10
8.1.170.0080.00018.72
8.1.160.0070.00022.16
8.1.150.0040.00418.79
8.1.140.0050.00319.19
8.1.130.0000.00717.85
8.1.120.0040.00417.52
8.1.110.0000.00917.31
8.1.100.0070.00017.46
8.1.90.0050.00317.54
8.1.80.0000.00717.48
8.1.70.0000.00717.36
8.1.60.0030.00617.52
8.1.50.0080.00017.50
8.1.40.0030.00617.43
8.1.30.0030.00517.61
8.1.20.0110.00017.73
8.1.10.0040.00417.56
8.1.00.0000.01017.45
8.0.300.0040.00419.60
8.0.290.0030.00716.75
8.0.280.0070.00018.35
8.0.270.0070.00017.27
8.0.260.0000.00718.54
8.0.250.0000.00816.98
8.0.240.0000.00816.88
8.0.230.0050.00216.97
8.0.220.0040.00416.90
8.0.210.0000.00816.89
8.0.200.0000.00616.88
8.0.190.0040.00416.96
8.0.180.0040.00416.91
8.0.170.0040.00416.86
8.0.160.0000.00816.92
8.0.150.0070.00016.71
8.0.140.0000.00716.77
8.0.130.0060.00013.33
8.0.120.0000.00716.83
8.0.110.0040.00416.80
8.0.100.0050.00316.84
8.0.90.0070.00016.91
8.0.80.0080.00816.93
8.0.70.0080.00016.77
8.0.60.0040.00416.89
8.0.50.0040.00416.76
8.0.30.0140.00917.15
8.0.20.0110.00817.40
8.0.10.0000.00817.02
8.0.00.0110.00816.73
7.4.330.0060.00015.03
7.4.320.0000.00616.63
7.4.300.0030.00316.38
7.4.290.0060.00316.46
7.4.280.0070.00016.56
7.4.270.0030.00316.51
7.4.260.0040.00416.51
7.4.250.0040.00416.59
7.4.240.0030.00316.53
7.4.230.0030.00316.50
7.4.220.0120.00616.58
7.4.210.0030.01316.70
7.4.200.0040.00416.70
7.4.160.0060.01016.63
7.4.150.0110.00617.40
7.4.140.0100.00817.86
7.4.130.0080.00816.52
7.4.120.0130.00516.55
7.4.110.0150.00716.55
7.4.100.0090.00916.44
7.4.90.0080.01116.57
7.4.80.0070.01319.39
7.4.70.0030.01716.37
7.4.60.0080.00816.37
7.4.50.0000.00816.27
7.4.40.0080.00916.61
7.4.30.0030.01316.66
7.4.00.0000.01414.96
7.3.330.0050.00013.15
7.3.320.0030.00313.20
7.3.310.0030.00316.48
7.3.300.0000.00716.34
7.3.290.0080.00616.37
7.3.280.0100.00816.34
7.3.270.0090.00917.40
7.3.260.0100.00716.30
7.3.250.0140.00316.41
7.3.240.0100.00716.58
7.3.230.0140.00616.39
7.3.210.0050.01116.57
7.3.200.0120.00919.39
7.3.190.0070.01016.62
7.3.180.0060.00916.27
7.3.170.0060.01516.45
7.3.160.0070.01016.26
7.2.330.0090.01316.38
7.2.320.0110.01116.73
7.2.310.0140.00416.66
7.2.300.0090.00616.58
7.2.290.0150.00316.71
7.2.00.0000.01719.34
7.1.100.0060.00617.75
7.1.70.0080.00817.16
7.1.60.0040.00719.46
7.1.50.0030.01716.90
7.1.00.0030.07722.35
7.0.200.0000.00816.41
7.0.140.0000.06322.11
7.0.60.0070.08719.98
7.0.50.0100.04717.84
7.0.40.0170.08020.26
7.0.30.0270.05320.04
7.0.20.0370.06320.16
7.0.10.0100.08720.09
7.0.00.0070.03720.15
5.6.280.0070.07020.93
5.6.210.0000.04320.71
5.6.200.0130.08018.19
5.6.190.0100.07020.45
5.6.180.0470.08020.49
5.6.170.0300.07720.33
5.6.160.0100.04720.54
5.6.150.0070.08318.09
5.6.140.0070.04018.16
5.6.130.0030.05718.11
5.6.120.0100.07720.98
5.6.110.0070.06021.11
5.6.100.0030.09020.96
5.6.90.0030.08720.95
5.6.80.0100.06020.43
5.5.350.0200.06320.43
5.5.340.0070.04318.02
5.5.330.0170.07720.40
5.5.320.0270.04020.20
5.5.310.0270.07320.50
5.5.300.0030.05317.91
5.5.290.0000.08718.00
5.5.280.0030.08320.76
5.5.270.0100.08020.74
5.5.260.0030.04320.76
5.5.250.0100.07720.49
5.5.240.0000.08020.18
5.4.450.0700.05019.64
5.4.440.0170.06719.50
5.4.430.0230.05019.63
5.4.420.0230.04719.32
5.4.410.0130.06019.47
5.4.400.0100.05718.78
5.4.390.0230.05318.50
5.4.380.0130.07018.70
5.4.370.0100.07018.66
5.4.360.0200.05318.69
5.4.350.0130.08018.69
5.4.340.0200.07318.75
5.4.320.0330.04018.63
5.4.310.0230.04718.55
5.4.300.0230.07018.69
5.4.290.0170.05718.65
5.4.280.0270.04718.66
5.4.270.0200.05318.49
5.4.260.0230.05018.45
5.4.250.0130.05718.45
5.4.240.0100.06318.48
5.4.230.0230.04718.45
5.4.220.0130.05718.51
5.4.210.0200.05018.66
5.4.200.0300.04016.65
5.4.190.0170.05318.59
5.4.180.0200.05018.44
5.4.170.0170.05318.48
5.4.160.0200.05018.54
5.4.150.0100.06018.68
5.4.140.0130.05316.31
5.4.130.0200.04716.26
5.4.120.0200.06716.19
5.4.110.0100.07316.23
5.4.100.0200.07016.13
5.4.90.0300.06016.07
5.4.80.0200.04716.35
5.4.70.0170.05016.28
5.4.60.0130.05716.23
5.4.50.0070.06316.29
5.4.40.0130.05316.27
5.4.30.0230.04316.22
5.4.20.0130.05316.22
5.4.10.0200.05716.22
5.4.00.0200.05015.64
5.3.290.0100.06314.60
5.3.280.0100.06014.60
5.3.270.0130.06314.50
5.3.260.0170.05314.54
5.3.250.0170.05014.64
5.3.240.0100.06014.56
5.3.230.0170.06314.63
5.3.220.0230.05314.46
5.3.210.0230.05714.66
5.3.200.0270.04314.46
5.3.190.0100.06314.46
5.3.180.0200.05314.51
5.3.170.0030.06714.66
5.3.160.0130.05314.46
5.3.150.0170.05714.48
5.3.140.0170.05314.65
5.3.130.0270.06014.53
5.3.120.0100.06014.62
5.3.110.0270.05014.45
5.3.100.0330.05013.99
5.3.90.0200.07314.12
5.3.80.0230.05014.00
5.3.70.0100.06014.02
5.3.60.0100.05713.98
5.3.50.0130.05714.04
5.3.40.0170.05013.86
5.3.30.0130.05313.86
5.3.20.0230.06713.62
5.3.10.0300.05713.66
5.3.00.0300.04713.60
5.2.170.0100.04311.17
5.2.160.0130.03711.07
5.2.150.0200.04011.14
5.2.140.0100.05011.10
5.2.130.0100.04311.06
5.2.120.0070.04311.27
5.2.110.0130.04011.15
5.2.100.0130.03711.16
5.2.90.0130.04011.16
5.2.80.0170.03711.06
5.2.70.0130.04311.09
5.2.60.0130.05011.09
5.2.50.0200.04011.05
5.2.40.0070.06010.95
5.2.30.0130.05711.13
5.2.20.0200.04711.00
5.2.10.0130.05010.88
5.2.00.0130.03710.75
5.1.60.0200.0409.97
5.1.50.0130.03310.02
5.1.40.0100.04310.11
5.1.30.0130.04010.29
5.1.20.0130.03710.38
5.1.10.0170.04010.09
5.1.00.0100.03710.08
5.0.50.0170.0208.68
5.0.40.0130.0238.45
5.0.30.0000.0538.25
5.0.20.0030.0308.22
5.0.10.0100.0278.17
5.0.00.0030.0478.34
4.4.90.0100.0175.91
4.4.80.0070.0205.81
4.4.70.0030.0335.89
4.4.60.0070.0205.93
4.4.50.0070.0235.92
4.4.40.0070.0375.87
4.4.30.0030.0235.82
4.4.20.0070.0205.95
4.4.10.0000.0305.92
4.4.00.0100.0305.95
4.3.110.0000.0275.85
4.3.100.0030.0275.82
4.3.90.0070.0205.79
4.3.80.0030.0375.84
4.3.70.0070.0205.89
4.3.60.0100.0275.79
4.3.50.0070.0205.80
4.3.40.0000.0405.75
4.3.30.0030.0234.74
4.3.20.0030.0234.74
4.3.10.0000.0274.74
4.3.00.0100.0306.97

preferences:
50.53 ms | 401 KiB | 5 Q