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; } 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.40.0100.00618.93
8.3.30.0110.00419.09
8.3.20.0070.00020.38
8.3.10.0000.00821.59
8.3.00.0030.00519.22
8.2.170.0110.00422.96
8.2.160.0110.00422.12
8.2.150.0090.00024.18
8.2.140.0060.00324.66
8.2.130.0050.00326.16
8.2.120.0080.00019.68
8.2.110.0060.00322.10
8.2.100.0060.00617.99
8.2.90.0000.00819.35
8.2.80.0050.00317.97
8.2.70.0030.00617.63
8.2.60.0040.00418.03
8.2.50.0000.00818.07
8.2.40.0040.00420.07
8.2.30.0040.00418.24
8.2.20.0020.00517.72
8.2.10.0030.00518.04
8.2.00.0030.00617.73
8.1.270.0130.00318.89
8.1.260.0000.00926.35
8.1.250.0070.00028.09
8.1.240.0090.00022.18
8.1.230.0040.00719.22
8.1.220.0040.00417.74
8.1.210.0030.00518.77
8.1.200.0030.01117.00
8.1.190.0040.00417.38
8.1.180.0000.00818.10
8.1.170.0100.00018.61
8.1.160.0040.00422.02
8.1.150.0000.00718.77
8.1.140.0040.00419.18
8.1.130.0000.00717.75
8.1.120.0030.00317.48
8.1.110.0040.00417.49
8.1.100.0040.00417.44
8.1.90.0030.00317.48
8.1.80.0040.00417.43
8.1.70.0080.00017.45
8.1.60.0030.00717.57
8.1.50.0050.00317.40
8.1.40.0040.00417.39
8.1.30.0040.00417.67
8.1.20.0050.00317.66
8.1.10.0000.00717.59
8.1.00.0000.00717.48
8.0.300.0070.00018.77
8.0.290.0030.00616.75
8.0.280.0000.00718.36
8.0.270.0000.00717.18
8.0.260.0040.00417.26
8.0.250.0040.00317.03
8.0.240.0040.00416.95
8.0.230.0000.00716.98
8.0.220.0040.00216.76
8.0.210.0000.00716.79
8.0.200.0000.00616.89
8.0.190.0080.00016.98
8.0.180.0000.00816.88
8.0.170.0030.00516.94
8.0.160.0040.00416.89
8.0.150.0040.00416.90
8.0.140.0030.00316.75
8.0.130.0030.00313.25
8.0.120.0080.00016.75
8.0.110.0040.00416.80
8.0.100.0040.00416.95
8.0.90.0000.00716.70
8.0.80.0060.00916.84
8.0.70.0040.00416.92
8.0.60.0000.00716.85
8.0.50.0050.00316.78
8.0.30.0160.00917.02
8.0.20.0110.01217.40
8.0.10.0030.00516.89
8.0.00.0060.01116.91
7.4.330.0030.00315.09
7.4.320.0000.00616.52
7.4.300.0040.00416.45
7.4.290.0040.00416.45
7.4.280.0040.00416.52
7.4.270.0000.00716.51
7.4.260.0040.00416.55
7.4.250.0040.00416.48
7.4.240.0030.00316.56
7.4.230.0030.00316.70
7.4.220.0130.00616.66
7.4.210.0080.00716.40
7.4.200.0000.00716.71
7.4.160.0120.00316.54
7.4.150.0060.01217.40
7.4.140.0120.01017.86
7.4.130.0100.00916.50
7.4.120.0090.00916.39
7.4.110.0080.01316.46
7.4.100.0160.00616.68
7.4.90.0070.01116.52
7.4.80.0130.00319.39
7.4.70.0140.00316.50
7.4.60.0120.00916.59
7.4.50.0040.00416.31
7.4.40.0040.01916.64
7.4.30.0130.00616.47
7.4.00.0030.01314.86
7.3.330.0000.00713.16
7.3.320.0000.00513.07
7.3.310.0000.00716.18
7.3.300.0040.00416.23
7.3.290.0070.00916.32
7.3.280.0050.01116.32
7.3.270.0100.01017.40
7.3.260.0120.00516.41
7.3.250.0070.01416.56
7.3.240.0100.00716.50
7.3.230.0090.00916.39
7.3.210.0070.01016.41
7.3.200.0110.00519.39
7.3.190.0080.00816.54
7.3.180.0030.01316.32
7.3.170.0120.00616.48
7.3.160.0030.01316.37
7.2.330.0100.00716.81
7.2.320.0030.01616.50
7.2.310.0110.00516.78
7.2.300.0090.00916.87
7.2.290.0140.00416.78
7.2.60.0070.00916.65
7.2.00.0030.00919.52
7.1.200.0000.01115.91
7.1.100.0070.00717.85
7.1.70.0040.00417.25
7.1.60.0070.01719.46
7.1.50.0070.01717.14
7.1.00.0030.07722.44
7.0.200.0000.00816.79
7.0.140.0070.07022.12
7.0.60.0000.08719.89
7.0.50.0030.04017.83
7.0.40.0200.07720.31
7.0.30.0170.04320.18
7.0.20.0330.03020.22
7.0.10.0030.05020.09
7.0.00.0130.04720.00
5.6.280.0070.07021.06
5.6.210.0070.03720.59
5.6.200.0030.04318.21
5.6.190.0100.06720.75
5.6.180.0400.06020.43
5.6.170.0370.07020.38
5.6.160.0100.08020.54
5.6.150.0070.08318.13
5.6.140.0070.05718.07
5.6.130.0030.08318.10
5.6.120.0030.04321.05
5.6.110.0100.06320.98
5.6.100.0100.06320.98
5.6.90.0030.09021.10
5.6.80.0130.05020.41
5.5.350.0330.07320.46
5.5.340.0070.04018.02
5.5.330.0130.03320.21
5.5.320.0070.08320.21
5.5.310.0330.06720.21
5.5.300.0100.07717.92
5.5.290.0100.08318.01
5.5.280.0000.09020.90
5.5.270.0000.04320.85
5.5.260.0170.07020.64
5.5.250.0130.07720.77
5.5.240.0030.05720.04
5.4.450.0400.06319.55
5.4.440.0200.05319.36
5.4.430.0200.05719.33
5.4.420.0070.06319.46
5.4.410.0170.06019.12
5.4.400.0200.05319.18
5.4.390.0400.06018.65
5.4.380.0370.06018.69
5.4.370.0270.06718.69
5.4.360.0300.06318.71
5.4.350.0200.06718.70
5.4.340.0130.07318.75
5.4.320.0200.07718.55
5.4.310.0300.06318.65
5.4.300.0270.05318.46
5.4.290.0300.06318.65
5.4.280.0200.06718.46
5.4.270.0270.05718.63
5.4.260.0170.06018.71
5.4.250.0230.05718.64
5.4.240.0070.06318.71
5.4.230.0170.05718.68
5.4.220.0230.06718.55
5.4.210.0200.05718.71
5.4.200.0230.05316.46
5.4.190.0230.05018.68
5.4.180.0330.05018.68
5.4.170.0300.05318.57
5.4.160.0270.05018.60
5.4.150.0170.05718.75
5.4.140.0270.05016.14
5.4.130.0170.06016.27
5.4.120.0230.06716.22
5.4.110.0230.05016.16
5.4.100.0130.06316.25
5.4.90.0330.04716.15
5.4.80.0230.05016.11
5.4.70.0170.07016.14
5.4.60.0130.05716.34
5.4.50.0200.07316.25
5.4.40.0230.04716.05
5.4.30.0230.05316.23
5.4.20.0330.05316.23
5.4.10.0270.06016.13
5.4.00.0200.06015.68
5.3.290.0200.06014.64
5.3.280.0270.05014.50
5.3.270.0200.06714.50
5.3.260.0330.05314.59
5.3.250.0300.04714.66
5.3.240.0300.04014.71
5.3.230.0230.05014.61
5.3.220.0200.06014.47
5.3.210.0270.05314.55
5.3.200.0130.08714.58
5.3.190.0230.05314.55
5.3.180.0230.05314.54
5.3.170.0130.06014.55
5.3.160.0230.05714.55
5.3.150.0170.05714.50
5.3.140.0270.05714.61
5.3.130.0270.05714.64
5.3.120.0230.05714.55
5.3.110.0330.06014.48
5.3.100.0200.06314.11
5.3.90.0200.05314.10
5.3.80.0200.05314.00
5.3.70.0170.05013.97
5.3.60.0270.04314.04
5.3.50.0230.05013.91
5.3.40.0130.05313.96
5.3.30.0130.05313.83
5.3.20.0130.06013.61
5.3.10.0330.04713.75
5.3.00.0200.05313.61
5.2.170.0130.04311.09
5.2.160.0230.04011.10
5.2.150.0130.05011.06
5.2.140.0130.05711.20
5.2.130.0300.03011.07
5.2.120.0130.04711.16
5.2.110.0170.04311.02
5.2.100.0100.04711.09
5.2.90.0100.04711.25
5.2.80.0170.04711.16
5.2.70.0130.04711.09
5.2.60.0230.03711.09
5.2.50.0230.04310.93
5.2.40.0100.04310.99
5.2.30.0130.04710.91
5.2.20.0200.03711.02
5.2.10.0100.04710.91
5.2.00.0230.04010.77
5.1.60.0100.04010.01
5.1.50.0130.04010.12
5.1.40.0130.03310.08
5.1.30.0130.03710.40
5.1.20.0170.05010.42
5.1.10.0230.03010.19
5.1.00.0100.03710.14
5.0.50.0100.0278.68
5.0.40.0170.0178.44
5.0.30.0030.0508.25
5.0.20.0030.0438.34
5.0.10.0030.0338.27
5.0.00.0130.0378.23
4.4.90.0100.0205.90
4.4.80.0100.0275.93
4.4.70.0070.0235.90
4.4.60.0200.0275.91
4.4.50.0070.0235.94
4.4.40.0070.0335.93
4.4.30.0030.0305.92
4.4.20.0070.0235.94
4.4.10.0130.0205.89
4.4.00.0130.0305.94
4.3.110.0130.0275.85
4.3.100.0170.0275.80
4.3.90.0000.0275.85
4.3.80.0070.0335.93
4.3.70.0030.0335.84
4.3.60.0070.0275.93
4.3.50.0130.0335.83
4.3.40.0100.0435.85
4.3.30.0070.0274.77
4.3.20.0100.0274.77
4.3.10.0070.0304.77
4.3.00.0100.0239.38

preferences:
48.78 ms | 400 KiB | 5 Q