3v4l.org

run code in 300+ PHP versions simultaneously
<?php $products = array( array('idproduct' => 1, 'amount' => 5), array('idproduct' => 2, 'amount' => 10), array('idproduct' => 3, 'amount' => 11), array('idproduct' => 4, 'amount' => 5) ); addOrOverride($products, array('idproduct' => 4, 'amount' => 5)); function addOrOverride(&$arr, $newItem) { $filtered = array_filter($arr, function($item) use($newItem) { return $item['idproduct'] == $newItem['idproduct']; }); if(count($filtered) > 0) { $key = key($filtered); $arr[$key] = array_merge($arr[$key], $newItem); } else { $arr[] = $newItem; } }

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.01416.50
8.3.50.0190.00416.39
8.3.40.0040.01118.76
8.3.30.0070.01118.68
8.3.20.0000.00818.82
8.3.10.0040.00420.57
8.3.00.0050.00319.38
8.2.180.0070.01418.16
8.2.170.0070.00722.96
8.2.160.0100.00321.05
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0040.00417.72
8.2.110.0060.00319.30
8.2.100.0000.01317.84
8.2.90.0000.00919.30
8.2.80.0070.00019.06
8.2.70.0000.00917.63
8.2.60.0000.01317.79
8.2.50.0030.00618.07
8.2.40.0000.00818.22
8.2.30.0040.00418.19
8.2.20.0040.00417.78
8.2.10.0000.00817.75
8.2.00.0120.00217.66
8.1.280.0070.00725.92
8.1.270.0070.00024.66
8.1.260.0080.00026.35
8.1.250.0030.00528.09
8.1.240.0060.00322.60
8.1.230.0120.00020.87
8.1.220.0000.00917.74
8.1.210.0000.00918.89
8.1.200.0050.00517.35
8.1.190.0000.00817.64
8.1.180.0040.00418.10
8.1.170.0030.00618.91
8.1.160.0030.00518.96
8.1.150.0040.00418.64
8.1.140.0000.00717.50
8.1.130.0000.00717.75
8.1.120.0050.00317.46
8.1.110.0080.00017.51
8.1.100.0000.00717.48
8.1.90.0090.00517.12
8.1.80.0000.00717.45
8.1.70.0030.00317.43
8.1.60.0080.00017.52
8.1.50.0050.00317.45
8.1.40.0000.00817.53
8.1.30.0000.00717.50
8.1.20.0000.00817.49
8.1.10.0080.00017.65
8.1.00.0000.00817.36
8.0.300.0030.00520.03
8.0.290.0050.00316.63
8.0.280.0070.00018.50
8.0.270.0000.00717.27
8.0.260.0030.00316.86
8.0.250.0070.00016.83
8.0.240.0070.00016.96
8.0.230.0040.00416.92
8.0.220.0000.00716.95
8.0.210.0070.00016.80
8.0.200.0000.00616.99
8.0.190.0090.00016.82
8.0.180.0000.00816.80
8.0.170.0000.00916.93
8.0.160.0030.00316.78
8.0.150.0080.00016.93
8.0.140.0090.00016.74
8.0.130.0000.00513.34
8.0.120.0040.00416.81
8.0.110.0040.00416.94
8.0.100.0060.00316.80
8.0.90.0070.00016.84
8.0.80.0110.00416.92
8.0.70.0040.00416.87
8.0.60.0050.00316.84
8.0.50.0050.00216.73
8.0.30.0070.01117.18
8.0.20.0110.01117.13
8.0.10.0030.00517.01
8.0.00.0090.00916.72
7.4.330.0000.00513.04
7.4.320.0030.00316.42
7.4.300.0060.00016.53
7.4.290.0050.00216.50
7.4.280.0080.00016.59
7.4.270.0030.00316.55
7.4.260.0000.00713.27
7.4.250.0030.00516.41
7.4.240.0040.00416.53
7.4.230.0000.00716.67
7.4.220.0090.01216.35
7.4.210.0070.00716.54
7.4.200.0030.00516.39
7.4.190.0080.00016.76
7.4.160.0080.00816.27
7.4.150.0120.00616.59
7.4.140.0110.00816.65
7.4.130.0090.00816.52
7.4.120.0140.00416.44
7.4.110.0030.01316.52
7.4.100.0080.00816.59
7.4.90.0120.00616.50
7.4.80.0060.01019.39
7.4.70.0070.01016.41
7.4.60.0000.01816.50
7.4.50.0040.00416.16
7.4.40.0030.01316.57
7.4.30.0080.00816.29
7.4.00.0070.01015.01
7.3.330.0060.00013.32
7.3.320.0030.00313.24
7.3.310.0030.00316.39
7.3.300.0030.00316.37
7.3.290.0060.00916.34
7.3.280.0060.01216.39
7.3.270.0130.01016.50
7.3.260.0090.00816.63
7.3.250.0120.00716.40
7.3.240.0110.00716.33
7.3.230.0090.00916.48
7.3.210.0120.00616.51
7.3.200.0090.01216.62
7.3.190.0160.00616.50
7.3.180.0060.01216.68
7.3.170.0160.01016.27
7.3.160.0060.01216.54
7.3.120.0030.01014.89
7.3.10.0040.01116.59
7.3.00.0000.01516.44
7.2.330.0060.01216.66
7.2.320.0120.00616.47
7.2.310.0080.01416.45
7.2.300.0070.01016.65
7.2.290.0030.01316.72
7.2.130.0070.01016.91
7.2.120.0000.01716.72
7.2.110.0040.01217.01
7.2.100.0060.00616.91
7.2.90.0030.01016.75
7.2.80.0030.01016.83
7.2.70.0060.00616.69
7.2.60.0040.00817.03
7.2.50.0080.00316.76
7.2.40.0100.00316.79
7.2.30.0040.00816.75
7.2.20.0070.00317.11
7.2.10.0120.00317.04
7.2.00.0080.00518.06
7.1.250.0090.00015.80
7.1.70.0030.00717.27
7.1.60.0100.01419.40
7.1.50.0250.01334.83
7.1.00.0030.03322.31
7.0.200.0080.00314.82
7.0.140.0070.07021.95
7.0.120.0070.05722.03
7.0.60.0170.05719.91
7.0.50.0100.07717.84
7.0.40.0100.04320.11
7.0.30.0070.04020.25
7.0.20.0100.03720.03
7.0.10.0000.04720.15
7.0.00.0000.04320.14
5.6.280.0070.07020.91
5.6.210.0070.05720.52
5.6.200.0100.07718.19
5.6.190.0000.04720.60
5.6.180.0030.04020.77
5.6.170.0030.05020.67
5.6.160.0030.04020.57
5.6.150.0030.04020.16
5.6.140.0030.04020.32
5.6.130.0030.04020.18
5.6.120.0000.04320.40
5.6.110.0030.04020.40
5.6.100.0070.03720.48
5.6.90.0170.04020.48
5.6.80.0070.08019.58
5.6.70.0130.07319.90
5.6.60.0100.08319.87
5.6.50.0100.04719.80
5.6.40.0100.05319.54
5.6.30.0100.07319.80
5.6.20.0030.04319.80
5.6.10.0070.04019.69
5.6.00.0000.05319.52
5.5.350.0070.06720.39
5.5.340.0070.07317.96
5.5.330.0030.05320.57
5.5.320.0000.04320.32
5.5.310.0030.05020.27
5.5.300.0070.04320.32
5.5.290.0070.04020.12
5.5.280.0070.04720.12
5.5.270.0030.04020.32
5.5.260.0000.04319.96
5.5.250.0070.04319.86
5.5.240.0070.08019.68
5.5.230.0000.05019.48
5.5.220.0100.03719.49
5.5.210.0070.05019.35
5.5.200.0230.06719.47
5.5.190.0000.04719.49
5.5.180.0030.04019.50
5.5.160.0130.04019.49
5.5.150.0100.05719.34
5.5.140.0030.05319.32
5.5.130.0030.06319.64
5.5.120.0030.08019.32
5.5.110.0130.04719.54
5.5.100.0100.07019.46
5.5.90.0100.04019.54
5.5.80.0070.04719.54
5.5.70.0100.07719.23
5.5.60.0030.07019.21
5.5.50.0130.07319.41
5.5.40.0100.04019.46
5.5.30.0070.05019.52
5.5.20.0100.07719.28
5.5.10.0030.08319.50
5.5.00.0230.06719.45
5.4.450.0030.04019.49
5.4.440.0000.04019.34
5.4.430.0030.03719.20
5.4.420.0030.03719.46
5.4.410.0030.03719.40
5.4.400.0070.07319.16
5.4.390.0070.07018.86
5.4.380.0100.04319.24
5.4.370.0130.06719.01
5.4.360.0070.07718.85
5.4.350.0100.05018.92
5.4.340.0030.04019.08
5.4.320.0170.07019.21
5.4.310.0130.06019.15
5.4.300.0070.03719.16
5.4.290.0030.07319.14
5.4.280.0000.04319.15
5.4.270.0030.04318.85
5.4.260.0100.07718.97
5.4.250.0130.06319.23
5.4.240.0130.06319.14
5.4.230.0130.07019.19
5.4.220.0070.07718.98
5.4.210.0000.04719.23
5.4.200.0100.04718.93
5.4.190.0100.03319.23
5.4.180.0030.05019.26
5.4.170.0030.06018.91
5.4.160.0100.03718.86
5.4.150.0100.07319.13
5.4.140.0070.04316.60
5.4.130.0100.06716.32
5.4.120.0130.04316.39
5.4.110.0100.03716.34
5.4.100.0030.05716.44
5.4.90.0130.06716.31
5.4.80.0070.03716.47
5.4.70.0100.05016.57
5.4.60.0000.08016.37
5.4.50.0070.06016.38
5.4.40.0070.06716.48
5.4.30.0030.06716.45
5.4.20.0030.05016.31
5.4.10.0100.05716.24
5.4.00.0100.07015.91
5.3.290.0100.03714.56
5.3.280.0030.04314.61
5.3.270.0100.03714.61
5.3.260.0070.08014.76
5.3.250.0030.04714.63
5.3.240.0100.07014.64
5.3.230.0030.04714.65
5.3.220.0000.04714.50
5.3.210.0030.08314.57
5.3.200.0030.05314.50
5.3.190.0100.06014.61
5.3.180.0070.07314.57
5.3.170.0030.04014.49
5.3.160.0030.07714.61
5.3.150.0100.07314.63
5.3.140.0070.07314.73
5.3.130.0070.08314.57
5.3.120.0070.06314.61
5.3.110.0130.07014.73
5.3.100.0070.07714.10
5.3.90.0100.07314.08
5.3.80.0100.07314.08
5.3.70.0130.03314.04
5.3.60.0100.06013.96
5.3.50.0100.07013.98
5.3.40.0100.07313.96
5.3.30.0130.06313.91
5.3.20.0000.04713.68
5.3.10.0130.03313.71
5.3.00.0070.07013.54
5.2.170.0000.04311.20
5.2.160.0070.04311.11
5.2.150.0130.05311.20
5.2.140.0030.04311.20
5.2.130.0000.06710.99
5.2.120.0100.04011.16
5.2.110.0070.03311.15
5.2.100.0030.06011.15
5.2.90.0030.05711.17
5.2.80.0000.06711.24
5.2.70.0100.06011.09
5.2.60.0100.06010.97
5.2.50.0070.06311.02
5.2.40.0070.04011.00
5.2.30.0130.05710.97
5.2.20.0170.05311.01
5.2.10.0000.06310.82
5.2.00.0000.04010.72
5.1.60.0000.0539.97
5.1.50.0000.04710.16
5.1.40.0000.04710.04
5.1.30.0000.05310.26
5.1.20.0070.05710.34
5.1.10.0030.05710.04
5.1.00.0070.05310.09
5.0.50.0000.0278.54
5.0.40.0070.0408.33
5.0.30.0130.0338.27
5.0.20.0100.0338.25
5.0.10.0000.0438.18
5.0.00.0070.0408.13
4.4.90.0000.0277.69
4.4.80.0070.0307.69
4.4.70.0000.0407.69
4.4.60.0000.0407.69
4.4.50.0030.0377.69
4.4.40.0030.0537.69
4.4.30.0000.0377.69
4.4.20.0000.0277.69
4.4.10.0070.0277.69
4.4.00.0030.0477.69
4.3.110.0000.0277.69
4.3.100.0000.0277.69
4.3.90.0030.0337.69
4.3.80.0000.0537.69
4.3.70.0030.0177.69
4.3.60.0030.0337.69
4.3.50.0000.0307.69
4.3.40.0070.0437.69
4.3.30.0000.0407.69
4.3.20.0000.0307.69
4.3.10.0000.0237.69
4.3.00.0030.0337.69

preferences:
57.3 ms | 401 KiB | 5 Q