3v4l.org

run code in 300+ PHP versions simultaneously
<?php function discount($cart){ $sum = array_sum($cart); if($sum >= 100) return 15; else if(count($cart) >= 3 and (isset($cart['A']) or isset($cart['B']))) return 10; else if(count($cart) >= 3) return 5; else return 0; } $carts = [ // product => price ['A' => 15, 'B' => 25], // no discount ['D' => 15, 'E' => 25, 'F' => 50], // any 3 ['A' => 15, 'B' => 25, 'D' => 35], // any 2 + 1 special ['A' => 15, 'B' => 25, 'C' => 50, 'D' => 75], // over amount x ]; foreach($carts as $cart){ echo (string)discount($cart), "\n"; }

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.0070.01116.58
8.3.60.0120.00318.31
8.3.50.0100.00518.29
8.3.40.0130.00618.67
8.3.30.0070.00718.76
8.3.20.0040.00420.32
8.3.10.0040.00418.90
8.3.00.0080.00023.53
8.2.190.0140.00316.63
8.2.180.0070.00718.16
8.2.170.0040.01222.96
8.2.160.0140.00020.34
8.2.150.0080.00024.18
8.2.140.0030.00524.66
8.2.130.0000.00826.16
8.2.120.0060.00319.66
8.2.110.0030.00921.11
8.2.100.0060.00617.84
8.2.90.0000.00917.97
8.2.80.0050.00318.28
8.2.70.0050.00317.63
8.2.60.0040.00417.75
8.2.50.0090.00017.63
8.2.40.0080.00019.48
8.2.30.0040.00419.37
8.2.20.0000.00718.03
8.2.10.0030.00618.05
8.2.00.0040.00418.02
8.1.280.0070.01025.92
8.1.270.0050.00322.14
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0100.00720.72
8.1.230.0040.00722.20
8.1.220.0040.00417.79
8.1.210.0080.00618.77
8.1.200.0030.00617.35
8.1.190.0080.00017.23
8.1.180.0030.00618.10
8.1.170.0050.00317.62
8.1.160.0040.00418.87
8.1.150.0040.00718.88
8.1.140.0030.00319.06
8.1.130.0030.00318.76
8.1.120.0080.00017.39
8.1.110.0070.00017.43
8.1.100.0050.00217.34
8.1.90.0030.00617.34
8.1.80.0040.00417.34
8.1.70.0000.00717.34
8.1.60.0070.00417.62
8.1.50.0030.00517.54
8.1.40.0040.00417.45
8.1.30.0040.00417.70
8.1.20.0020.00517.61
8.1.10.0000.00817.55
8.1.00.0030.00617.41
8.0.300.0040.00419.98
8.0.290.0000.00716.75
8.0.280.0040.00418.44
8.0.270.0030.00316.82
8.0.260.0070.00016.85
8.0.250.0080.00316.98
8.0.240.0030.00316.84
8.0.230.0030.00316.91
8.0.220.0000.00716.86
8.0.210.0000.00716.85
8.0.200.0060.00016.88
8.0.190.0050.00316.93
8.0.180.0040.00416.87
8.0.170.0040.00416.88
8.0.160.0070.00316.89
8.0.150.0040.00416.91
8.0.140.0040.00416.82
8.0.130.0000.00613.39
8.0.120.0000.00816.82
8.0.110.0000.00716.77
8.0.100.0050.00316.73
8.0.90.0000.00816.91
8.0.80.0150.00616.88
8.0.70.0000.00716.84
8.0.60.0000.00716.86
8.0.50.0000.00716.78
8.0.30.0100.01016.97
8.0.20.0100.01017.40
8.0.10.0030.00517.04
8.0.00.0120.01116.60
7.4.330.0050.00015.55
7.4.320.0030.00316.51
7.4.300.0060.00016.43
7.4.290.0040.00416.50
7.4.280.0030.00616.56
7.4.270.0030.00316.52
7.4.260.0000.00816.46
7.4.250.0000.00716.39
7.4.240.0040.00416.60
7.4.230.0000.00716.57
7.4.220.0000.00716.50
7.4.210.0070.00816.58
7.4.200.0040.00416.43
7.4.160.0090.00816.42
7.4.150.0100.00717.40
7.4.140.0090.01017.86
7.4.130.0070.01016.48
7.4.120.0110.01216.45
7.4.110.0070.01016.38
7.4.100.0070.01116.63
7.4.90.0180.00416.45
7.4.80.0100.01319.39
7.4.70.0120.00916.52
7.4.60.0110.00716.38
7.4.50.0070.01116.68
7.4.40.0000.01716.27
7.4.30.0120.01216.52
7.4.00.0050.01214.88
7.3.330.0030.00313.11
7.3.320.0030.00313.16
7.3.310.0060.00316.35
7.3.300.0040.00416.33
7.3.290.0140.00316.25
7.3.280.0090.00916.28
7.3.270.0090.00917.40
7.3.260.0080.00916.47
7.3.250.0110.00916.44
7.3.240.0120.01016.35
7.3.230.0090.00916.56
7.3.210.0130.00416.43
7.3.200.0130.00316.35
7.3.190.0080.00916.42
7.3.180.0120.00416.38
7.3.170.0070.01116.42
7.3.160.0130.00916.55
7.3.120.0070.01014.46
7.3.110.0110.00414.98
7.3.100.0000.01214.51
7.3.90.0070.00714.54
7.3.80.0040.00414.86
7.3.70.0000.01314.82
7.3.60.0030.00714.86
7.3.50.0040.01114.95
7.3.40.0110.00414.55
7.3.30.0090.00614.60
7.3.20.0000.01716.27
7.3.10.0000.01316.67
7.3.00.0060.00316.59
7.2.330.0110.00716.80
7.2.320.0100.00716.69
7.2.310.0080.00916.82
7.2.300.0100.01116.48
7.2.290.0100.01016.57
7.2.250.0090.00915.23
7.2.240.0040.01515.00
7.2.230.0000.01015.12
7.2.220.0070.00615.23
7.2.210.0130.00314.92
7.2.200.0070.00714.98
7.2.190.0000.01315.03
7.2.180.0030.01014.73
7.2.170.0040.01515.08
7.2.60.0060.00617.02
7.2.00.0070.00419.89
7.1.330.0000.01415.76
7.1.320.0030.01015.70
7.1.310.0030.00815.88
7.1.300.0030.01015.75
7.1.290.0070.00715.55
7.1.280.0090.00615.78
7.1.270.0070.00715.47
7.1.260.0030.01315.81
7.1.200.0090.00315.79
7.1.120.0000.01018.70
7.1.110.0060.00318.14
7.1.100.0030.00618.29
7.1.90.0070.00418.13
7.1.80.0000.01018.08
7.1.70.0060.00317.24
7.1.60.0170.00334.91
7.1.50.0140.00734.87
7.1.40.0090.01334.42
7.1.30.0130.00934.50
7.1.20.0090.01234.63
7.1.10.0000.01016.43
7.1.00.0070.00316.43

preferences:
61.4 ms | 401 KiB | 5 Q