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; $id = key($vouchers2); $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); $id = key($vouchers); $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.0160.00318.28
8.3.50.0140.00422.01
8.3.40.0090.00618.66
8.3.30.0140.00019.25
8.3.20.0080.00020.22
8.3.10.0030.00521.95
8.3.00.0000.00819.05
8.2.180.0100.01016.50
8.2.170.0090.00622.96
8.2.160.0170.00322.07
8.2.150.0080.00024.18
8.2.140.0000.00924.66
8.2.130.0040.01126.16
8.2.120.0060.00319.77
8.2.110.0000.00922.18
8.2.100.0000.01219.57
8.2.90.0000.00819.26
8.2.80.0050.00317.97
8.2.70.0050.00317.75
8.2.60.0060.00318.03
8.2.50.0000.00818.07
8.2.40.0030.00519.95
8.2.30.0000.00818.05
8.2.20.0000.00817.80
8.2.10.0000.00818.23
8.2.00.0000.00717.80
8.1.280.0170.00025.92
8.1.270.0060.00318.75
8.1.260.0080.00026.35
8.1.250.0090.00028.09
8.1.240.0060.00323.74
8.1.230.0070.00419.16
8.1.220.0000.00817.79
8.1.210.0060.00318.77
8.1.200.0090.00017.12
8.1.190.0050.00317.11
8.1.180.0080.00018.10
8.1.170.0050.00318.40
8.1.160.0050.00322.07
8.1.150.0040.00418.89
8.1.140.0040.00419.22
8.1.130.0000.00717.94
8.1.120.0050.00217.33
8.1.110.0030.00517.43
8.1.100.0040.00417.53
8.1.90.0040.00417.36
8.1.80.0000.00717.35
8.1.70.0030.00317.47
8.1.60.0070.00317.63
8.1.50.0030.00617.42
8.1.40.0060.00317.58
8.1.30.0030.00517.64
8.1.20.0030.00617.65
8.1.10.0000.00717.54
8.1.00.0060.00317.51
8.0.300.0080.00018.77
8.0.290.0000.00716.63
8.0.280.0070.00018.41
8.0.270.0000.00817.18
8.0.260.0000.00717.20
8.0.250.0040.00416.94
8.0.240.0040.00416.95
8.0.230.0070.00016.86
8.0.220.0050.00316.92
8.0.210.0000.00716.82
8.0.200.0000.00616.95
8.0.190.0000.00816.86
8.0.180.0000.00816.89
8.0.170.0040.00416.93
8.0.160.0040.00416.86
8.0.150.0000.00716.88
8.0.140.0000.00716.78
8.0.130.0000.00613.39
8.0.120.0040.00416.89
8.0.110.0000.00716.79
8.0.100.0040.00416.75
8.0.90.0000.00716.95
8.0.80.0130.00316.92
8.0.70.0040.00416.78
8.0.60.0040.00416.96
8.0.50.0050.00316.92
8.0.30.0170.00916.86
8.0.20.0100.00917.40
8.0.10.0020.00517.06
8.0.00.0100.00816.93
7.4.330.0000.00515.03
7.4.320.0000.00616.37
7.4.300.0000.00616.58
7.4.290.0000.00816.53
7.4.280.0080.00016.42
7.4.270.0030.00316.57
7.4.260.0030.00316.57
7.4.250.0050.00216.45
7.4.240.0020.00516.56
7.4.230.0000.00816.69
7.4.220.0060.01216.51
7.4.210.0060.01016.59
7.4.200.0000.00816.63
7.4.160.0130.00316.38
7.4.150.0090.01017.40
7.4.140.0120.00717.86
7.4.130.0100.00916.60
7.4.120.0080.01016.50
7.4.110.0170.01016.51
7.4.100.0160.00316.56
7.4.90.0080.01116.56
7.4.80.0180.00719.39
7.4.70.0070.01216.53
7.4.60.0060.00916.48
7.4.50.0000.00816.18
7.4.40.0100.00716.62
7.4.30.0060.01616.46
7.4.00.0030.01015.01
7.3.330.0030.00313.16
7.3.320.0030.00313.09
7.3.310.0000.00816.17
7.3.300.0070.00016.38
7.3.290.0080.00816.32
7.3.280.0070.01216.30
7.3.270.0140.01117.40
7.3.260.0100.00716.33
7.3.250.0110.00816.36
7.3.240.0090.01516.23
7.3.230.0100.01316.41
7.3.210.0120.00916.60
7.3.200.0120.00619.39
7.3.190.0060.01016.49
7.3.180.0090.00816.23
7.3.170.0090.01216.27
7.3.160.0110.00516.59
7.2.330.0130.00316.75
7.2.320.0120.01216.76
7.2.310.0140.00416.71
7.2.300.0100.00716.65
7.2.290.0140.01116.77
7.2.60.0100.00716.95
7.2.00.0060.00319.58
7.1.200.0060.00615.58
7.1.100.0000.00917.93
7.1.70.0040.00417.18
7.1.60.0100.01619.46
7.1.50.0000.01216.64
7.1.00.0030.07722.51
7.0.200.0000.01016.47
7.0.140.0000.06722.01
7.0.60.0100.07720.00
7.0.50.0130.07317.84
7.0.40.0030.06320.05
7.0.30.0170.04020.21
7.0.20.0330.06320.04
7.0.10.0030.07020.18
7.0.00.0100.07720.16
5.6.280.0030.07721.05
5.6.210.0030.04020.65
5.6.200.0070.07718.20
5.6.190.0100.08320.41
5.6.180.0270.04720.35
5.6.170.0230.06720.33
5.6.160.0000.06320.48
5.6.150.0170.07018.17
5.6.140.0200.06018.18
5.6.130.0070.06718.12
5.6.120.0030.05021.13
5.6.110.0030.06320.98
5.6.100.0100.07721.11
5.6.90.0170.08321.11
5.6.80.0030.06720.38
5.5.350.0230.07720.43
5.5.340.0030.07017.93
5.5.330.0130.06020.57
5.5.320.0000.08020.18
5.5.310.0370.05720.18
5.5.300.0130.07318.04
5.5.290.0000.05017.96
5.5.280.0070.08320.85
5.5.270.0030.06320.63
5.5.260.0130.07720.88
5.5.250.0070.08020.62
5.5.240.0070.06720.08
5.4.450.0430.06719.63
5.4.440.0500.05719.62
5.4.430.0530.04719.53
5.4.420.0500.05719.60
5.4.410.0770.04719.34
5.4.400.0530.05019.21
5.4.390.0230.05718.61
5.4.380.0230.06318.71
5.4.370.0230.07718.67
5.4.360.0270.05018.47
5.4.350.0230.05718.58
5.4.340.0230.06318.60
5.4.320.0170.06318.70
5.4.310.0230.05318.47
5.4.300.0300.06318.63
5.4.290.0070.06718.50
5.4.280.0200.06718.68
5.4.270.0200.07318.46
5.4.260.0200.05718.46
5.4.250.0370.05718.65
5.4.240.0230.05718.70
5.4.230.0500.06318.70
5.4.220.0370.06318.68
5.4.210.0330.06718.48
5.4.200.0170.08016.50
5.4.190.0300.07018.64
5.4.180.0270.07718.64
5.4.170.0300.06718.68
5.4.160.0270.07018.67
5.4.150.0300.05018.75
5.4.140.0270.05316.14
5.4.130.0200.06016.23
5.4.120.0170.07316.26
5.4.110.0170.07016.23
5.4.100.0230.04716.05
5.4.90.0230.05316.20
5.4.80.0270.04716.24
5.4.70.0200.06016.15
5.4.60.0130.07316.16
5.4.50.0300.04016.20
5.4.40.0330.04716.30
5.4.30.0300.04716.07
5.4.20.0100.07016.13
5.4.10.0200.05316.29
5.4.00.0230.04715.53
5.3.290.0170.06314.60
5.3.280.0130.07714.50
5.3.270.0070.06714.63
5.3.260.0070.07014.71
5.3.250.0070.06314.59
5.3.240.0200.06014.65
5.3.230.0170.06714.60
5.3.220.0100.06314.61
5.3.210.0200.07314.57
5.3.200.0300.06014.55
5.3.190.0230.06314.63
5.3.180.0270.06014.63
5.3.170.0170.07714.63
5.3.160.0270.06314.48
5.3.150.0170.07314.58
5.3.140.0230.06314.55
5.3.130.0300.05014.65
5.3.120.0130.06314.65
5.3.110.0130.06714.65
5.3.100.0200.06014.14
5.3.90.0100.06013.94
5.3.80.0100.06014.13
5.3.70.0300.04314.13
5.3.60.0170.05713.96
5.3.50.0270.06013.87
5.3.40.0500.04013.99
5.3.30.0300.06013.90
5.3.20.0300.05013.82
5.3.10.0170.05013.64
5.3.00.0400.05713.61
5.2.170.0100.06711.20
5.2.160.0170.05311.14
5.2.150.0200.05711.14
5.2.140.0200.05311.19
5.2.130.0170.04311.03
5.2.120.0130.04011.16
5.2.110.0130.05011.10
5.2.100.0200.05311.07
5.2.90.0170.04711.05
5.2.80.0130.04311.09
5.2.70.0200.04311.06
5.2.60.0200.05310.98
5.2.50.0200.05311.07
5.2.40.0100.04310.98
5.2.30.0170.04011.02
5.2.20.0170.04010.93
5.2.10.0070.04310.92
5.2.00.0070.04710.84
5.1.60.0130.03010.13
5.1.50.0130.03710.04
5.1.40.0200.03310.17
5.1.30.0200.03710.55
5.1.20.0130.04710.46
5.1.10.0200.03010.10
5.1.00.0130.03710.26
5.0.50.0100.0308.64
5.0.40.0070.0408.53
5.0.30.0070.0578.43
5.0.20.0130.0308.24
5.0.10.0200.0238.32
5.0.00.0000.0578.38
4.4.90.0100.0305.90
4.4.80.0100.0235.89
4.4.70.0030.0275.84
4.4.60.0100.0275.84
4.4.50.0030.0335.90
4.4.40.0000.0405.90
4.4.30.0070.0275.92
4.4.20.0030.0305.90
4.4.10.0100.0236.00
4.4.00.0070.0405.95
4.3.110.0130.0205.83
4.3.100.0030.0275.86
4.3.90.0070.0235.82
4.3.80.0070.0435.91
4.3.70.0100.0235.84
4.3.60.0130.0135.91
4.3.50.0070.0235.81
4.3.40.0130.0335.85
4.3.30.0030.0304.91
4.3.20.0030.0304.91
4.3.10.0030.0234.91
4.3.00.0100.0239.38

preferences:
53.68 ms | 401 KiB | 5 Q