3v4l.org

run code in 300+ PHP versions simultaneously
<?php $order = 99; $sizes=[21,18,12,6]; $b = [21 => 0, 18 => 0, 12 => 0, 6 => 0]; // number of 21 boxes possible if($order >= 21){ $b[21] = floor($order/21); $order -= $b[21]*21; } // if the remainder needs to be modified to be divisible on 6 while($order % 6 != 0){ if($b[21] > 0){ // remove one box of 21 and add the bottles back to the remainder $order += 21; $b[21]--; }else{ // if we run out of 21 boxes then the order is not possible. echo "order not possible"; exit; } } // split up the remainder on 18/12/6 boxes and remove empty boxes $b = array_filter(split_up($b, $order)); var_dump($b); function split_up($b, $order){ // number of 18 boxes possible if($order >= 18){ $b[18] = floor($order/18); $order -= $b[18]*18; } // number of 12 boxes possible if($order >= 12){ $b[12] = floor($order/12); $order -= $b[12]*12; } // number of 6 boxes possible if($order >= 6){ $b[6] = floor($order/6); $order -= $b[6]*6; } return $b; }

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.4.140.0120.00917.72
8.4.130.0090.01018.89
8.4.120.0120.00824.01
8.4.110.0090.01220.58
8.4.100.0110.00717.57
8.4.90.0130.00720.48
8.4.80.0110.00918.85
8.4.70.0130.00918.84
8.4.60.0130.00520.86
8.4.50.0130.00624.37
8.4.40.0120.00919.51
8.4.30.0130.00618.83
8.4.20.0130.01018.54
8.4.10.0290.00518.61
8.3.270.0110.00916.52
8.3.260.0050.00516.78
8.3.250.0080.01119.10
8.3.240.0110.00517.16
8.3.230.0110.00816.58
8.3.220.0080.01018.76
8.3.210.0090.00916.52
8.3.200.0110.00916.55
8.3.190.0120.00417.32
8.3.180.0100.00916.41
8.3.170.0190.00016.67
8.3.160.0100.01016.72
8.3.150.0230.00516.43
8.3.140.0040.00417.04
8.3.130.0130.00317.23
8.3.120.0110.00117.73
8.3.110.0120.00218.66
8.3.100.0140.00520.38
8.3.90.0100.00416.69
8.3.80.0110.00317.42
8.3.70.0110.00717.37
8.3.60.0100.01217.60
8.3.50.0130.01017.09
8.3.40.0120.00818.21
8.3.30.0120.00718.02
8.3.20.0120.00519.50
8.3.10.0090.00819.70
8.3.00.0080.00820.12
8.2.290.0100.00120.49
8.2.280.0110.00818.39
8.2.270.0170.00016.57
8.2.260.0030.00917.81
8.2.250.0120.00217.46
8.2.240.0070.00816.72
8.2.230.0090.00419.63
8.2.220.0100.00327.07
8.2.210.0100.00321.69
8.2.200.0110.00116.50
8.2.190.0140.00416.32
8.2.180.0120.00717.35
8.2.170.0120.00720.27
8.2.160.0100.00918.63
8.2.150.0120.00320.89
8.2.140.0060.00620.98
8.2.130.0140.00521.72
8.2.120.0070.00519.42
8.2.110.0090.00720.67
8.2.100.0120.00519.31
8.2.90.0190.00218.12
8.2.80.0150.00018.48
8.2.70.0140.00718.59
8.2.60.0180.00317.95
8.2.50.0100.00618.52
8.2.40.0120.00418.05
8.2.30.0080.00618.64
8.2.20.0120.00218.89
8.2.10.0120.00218.63
8.2.00.0090.00618.54
8.1.330.0060.00421.90
8.1.320.0100.01017.91
8.1.310.0070.01017.39
8.1.300.0120.00216.91
8.1.290.0090.00517.31
8.1.280.0110.01020.98
8.1.270.0080.00720.72
8.1.260.0100.00321.86
8.1.250.0080.00622.58
8.1.240.0090.00418.25
8.1.230.0110.00417.84
8.1.220.0120.00717.92
8.1.210.0090.00718.65
8.1.200.0110.00317.75
8.1.190.0100.00418.11
8.1.180.0150.00517.94
8.1.170.0080.00617.63
8.1.160.0100.00518.19
8.1.150.0110.00418.86
8.1.140.0080.00418.83
8.1.130.0070.00618.69
8.1.120.0090.00417.79
8.1.110.0080.00618.13
8.1.100.0150.00417.75
8.1.90.0120.00317.82
8.1.80.0130.00417.78
8.1.70.0080.00517.85
8.1.60.0130.00117.92
8.1.50.0110.00417.71
8.1.40.0120.00218.00
8.1.30.0090.00418.10
8.1.20.0110.00317.96
8.1.10.0090.00517.83
8.1.00.0060.00617.90
8.0.300.0090.00517.62
8.0.290.0090.00517.12
8.0.280.0120.00417.58
8.0.270.0090.00517.12
8.0.260.0060.00518.32
8.0.250.0120.00217.20
8.0.240.0070.00517.24
8.0.230.0100.00317.29
8.0.220.0100.00217.11
8.0.210.0080.00417.06
8.0.200.0080.00517.26
8.0.190.0080.00517.39
8.0.180.0070.00517.08
8.0.170.0090.00417.20
8.0.160.0090.00617.07
8.0.150.0080.00417.11
8.0.140.0070.00617.12
8.0.130.0070.00416.09
8.0.120.0080.00517.11
8.0.110.0110.00117.18
8.0.100.0100.00317.13
8.0.90.0090.00517.08
8.0.80.0130.00817.15
8.0.70.0120.00517.05
8.0.60.0110.00217.11
8.0.50.0090.00316.99
8.0.30.0110.00317.31
8.0.20.0110.00617.22
8.0.10.0110.00217.33
8.0.00.0100.00619.22
7.4.330.0100.00116.10
7.4.320.0110.00116.87
7.4.300.0070.00317.43
7.4.290.0060.00417.42
7.4.280.0100.00216.89
7.4.270.0090.00117.45
7.4.260.0080.00416.89
7.4.250.0070.00316.88
7.4.240.0110.00116.72
7.4.230.0090.00316.94
7.4.220.0050.00417.28
7.4.210.0090.00616.80
7.4.200.0060.00417.45
7.4.190.0100.00317.05
7.4.180.0080.00516.97
7.4.160.0090.00217.85
7.4.150.0050.00517.73
7.4.140.0090.00217.82
7.4.130.0100.00416.70
7.4.120.0120.00516.72
7.4.110.0140.00216.77
7.4.100.0110.00516.82
7.4.90.0180.00416.76
7.4.80.0120.01017.59
7.4.70.0210.00416.85
7.4.60.0160.00616.79
7.4.50.0120.00516.66
7.4.40.0120.00416.78
7.4.30.0120.00316.96
7.4.20.0120.00216.87
7.4.10.0110.00416.86
7.4.00.0040.00916.76
7.3.330.0080.00416.66
7.3.320.0100.00215.57
7.3.310.0120.00216.60
7.3.300.0100.00516.62
7.3.290.0090.00716.67
7.3.280.0120.00316.66
7.3.270.0090.00716.70
7.3.260.0110.00816.60
7.3.250.0140.00317.01
7.3.240.0170.00616.54
7.3.230.0100.00516.72
7.3.220.0130.00417.37
7.3.210.0110.00816.52
7.3.200.0090.00916.65
7.3.190.0070.00916.63
7.3.180.0100.00816.65
7.3.170.0100.00617.18
7.3.160.0090.00716.59
7.3.150.0130.00316.87
7.3.140.0140.00317.50
7.3.130.0120.00417.64
7.3.120.0080.00816.59
7.3.110.0090.00616.65
7.3.100.0130.00316.42
7.3.90.0120.00316.21
7.3.80.0080.00815.99
7.3.70.0080.00716.72
7.3.60.0080.00816.08
7.3.50.0100.00516.20
7.3.40.0110.00416.02
7.3.30.0070.00616.19
7.3.20.0120.00417.94
7.3.10.0130.00417.93
7.3.00.0070.00717.74
7.2.340.0110.00416.80
7.2.330.0120.00516.74
7.2.320.0130.00617.38
7.2.310.0110.00716.56
7.2.300.0080.00816.77
7.2.290.0080.00816.83
7.2.280.0130.00417.68
7.2.270.0090.00616.69
7.2.260.0130.00216.60
7.2.250.0150.00217.69
7.2.240.0120.00416.62
7.2.230.0090.00616.78
7.2.220.0150.00116.09
7.2.210.0110.00616.21
7.2.200.0130.00216.18
7.2.190.0120.00316.23
7.2.180.0090.00716.73
7.2.170.0090.00716.36
7.2.160.0100.00516.22
7.2.150.0130.00418.71
7.2.140.0140.00318.08
7.2.130.0120.00418.31
7.2.120.0080.00818.16
7.2.110.0110.00518.20
7.2.100.0120.00418.11
7.2.90.0150.00218.01
7.2.80.0140.00218.18
7.2.70.0100.00518.16
7.2.60.0100.00618.20
7.2.50.0090.00718.18
7.2.40.0110.00418.27
7.2.30.0120.00318.22
7.2.20.0120.00418.27
7.2.10.0090.00518.71
7.2.00.0090.00618.12
7.1.330.0060.00417.77
7.1.320.0110.00517.02
7.1.310.0120.00317.18
7.1.300.0120.00317.02
7.1.290.0120.00517.10
7.1.280.0120.00517.14
7.1.270.0090.00617.09
7.1.260.0050.00817.02
7.1.250.0070.00716.92
7.1.240.0100.00517.71
7.1.230.0110.00317.59
7.1.220.0130.00417.58
7.1.210.0150.00217.74
7.1.200.0150.00217.80
7.1.190.0180.00417.72
7.1.180.0150.00017.69
7.1.170.0140.00018.13
7.1.160.0180.00117.52
7.1.150.0140.00617.56
7.1.140.0130.00517.75
7.1.130.0110.00417.61
7.1.120.0090.00617.48
7.1.110.0180.00417.67
7.1.100.0100.00517.65
7.1.90.0090.00517.67
7.1.80.0160.00117.74
7.1.70.0170.00217.41
7.1.60.0170.00017.72
7.1.50.0170.00217.84
7.1.40.0150.00117.65
7.1.30.0110.00417.71
7.1.20.0120.00317.56
7.1.10.0150.00017.74
7.1.00.0130.00217.77

preferences:
32.77 ms | 403 KiB | 5 Q