3v4l.org

run code in 300+ PHP versions simultaneously
<?php function arrayMergeRecursiveDistinct(array $first, array $second) { foreach ($second as $idx => $value) { if (is_integer($idx)) { $first[] = $value; } else { if (!array_key_exists($idx, $first)) { $first[$idx] = $value; } else { if (is_array($value)) { $first[$idx] = arrayMergeRecursiveDistinct($first[$idx], $value); } else { $first[$idx] = $value; } } } } return $first; } $a = ['a' => [1,2,3], 'b' => ['c' => ['d' => 'e']]]; $b = ['a' => [1,2,3,4], 'b']; print_r(arrayMergeRecursiveDistinct($b, $a)); print_r(array_replace_recursive($b, $a));

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.0150.00018.41
8.3.50.0080.00621.07
8.3.40.0120.00318.80
8.3.30.0180.00019.08
8.3.20.0000.00820.16
8.3.10.0040.00420.47
8.3.00.0080.00017.59
8.2.180.0170.00316.63
8.2.170.0110.00422.96
8.2.160.0050.00820.35
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0000.00726.16
8.2.120.0040.00422.25
8.2.110.0000.00921.04
8.2.100.0080.00318.03
8.2.90.0030.00619.17
8.2.80.0050.00317.97
8.2.70.0000.00817.75
8.2.60.0040.00417.93
8.2.50.0060.00618.07
8.2.40.0080.00018.28
8.2.30.0040.00419.14
8.2.20.0070.00017.74
8.2.10.0030.00618.19
8.2.00.0040.00417.64
8.1.280.0070.01125.92
8.1.270.0050.00322.09
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0050.00520.72
8.1.230.0070.00417.89
8.1.220.0040.00417.78
8.1.210.0000.00818.77
8.1.200.0040.00417.35
8.1.190.0080.00017.23
8.1.180.0000.00818.10
8.1.170.0030.00918.44
8.1.160.0030.00522.03
8.1.150.0070.00018.90
8.1.140.0040.00417.47
8.1.130.0040.00417.79
8.1.120.0040.00417.37
8.1.110.0080.00017.36
8.1.100.0070.00017.37
8.1.90.0000.00717.52
8.1.80.0040.00417.37
8.1.70.0000.00717.35
8.1.60.0050.00317.64
8.1.50.0030.00717.43
8.1.40.0030.00617.39
8.1.30.0030.00617.63
8.1.20.0030.00617.52
8.1.10.0040.00417.57
8.1.00.0070.00317.36
8.0.300.0000.00718.77
8.0.290.0030.00516.75
8.0.280.0030.00318.45
8.0.270.0030.00317.22
8.0.260.0000.00617.19
8.0.250.0030.00317.01
8.0.240.0060.00316.86
8.0.230.0030.00316.87
8.0.220.0030.00316.85
8.0.210.0000.00716.83
8.0.200.0060.00316.98
8.0.190.0000.00716.84
8.0.180.0030.00516.88
8.0.170.0090.00016.92
8.0.160.0030.00316.82
8.0.150.0030.00516.86
8.0.140.0030.00616.82
8.0.130.0000.00513.32
8.0.120.0000.00816.71
8.0.110.0000.00716.91
8.0.100.0030.00616.93
8.0.90.0000.00716.77
8.0.80.0140.00316.84
8.0.70.0030.00616.81
8.0.60.0000.00716.93
8.0.50.0030.00516.88
8.0.30.0080.01117.13
8.0.20.0060.01517.40
8.0.10.0060.00316.91
8.0.00.0090.00916.81
7.4.330.0000.00515.05
7.4.320.0060.00016.50
7.4.300.0000.00716.62
7.4.290.0070.00016.51
7.4.280.0000.00616.58
7.4.270.0030.00316.51
7.4.260.0000.00816.50
7.4.250.0000.00716.48
7.4.240.0020.00516.57
7.4.230.0070.00016.51
7.4.220.0070.01416.53
7.4.210.0090.01216.45
7.4.200.0000.00716.73
7.4.160.0060.00916.43
7.4.150.0030.01617.40
7.4.140.0140.00617.86
7.4.130.0080.00916.41
7.4.120.0070.01016.59
7.4.110.0090.00916.55
7.4.100.0140.00416.61
7.4.90.0060.01116.59
7.4.80.0110.00919.37
7.4.70.0030.01316.55
7.4.60.0060.01016.52
7.4.50.0050.00316.20
7.4.40.0030.01316.44
7.4.30.0080.00816.48
7.4.00.0030.01415.05
7.3.330.0000.00513.35
7.3.320.0060.00013.38
7.3.310.0000.00716.39
7.3.300.0030.00316.42
7.3.290.0100.00316.37
7.3.280.0080.00816.38
7.3.270.0120.00617.40
7.3.260.0170.00316.41
7.3.250.0120.00916.29
7.3.240.0130.00316.73
7.3.230.0040.01216.41
7.3.210.0070.01016.66
7.3.200.0110.00619.39
7.3.190.0090.01216.34
7.3.180.0060.01016.32
7.3.170.0060.00916.43
7.3.160.0100.00616.25
7.2.330.0070.01016.61
7.2.320.0130.01016.87
7.2.310.0120.00716.63
7.2.300.0030.01716.63
7.2.290.0120.00616.75
7.1.200.0090.00615.91
7.1.70.0050.00517.09
7.1.60.0100.00719.32
7.1.50.0040.01916.91
7.1.00.0000.07722.57
7.0.200.0070.00316.76
7.0.140.0030.07321.93
7.0.60.0030.06019.83
7.0.50.0030.04017.73
7.0.40.0100.03719.96
7.0.30.0370.05320.06
7.0.20.0200.04320.12
7.0.10.0070.04020.22
7.0.00.0000.05320.20
5.6.280.0070.07021.12
5.6.210.0030.04020.55
5.6.200.0030.08718.19
5.6.190.0070.08320.67
5.6.180.0470.05320.75
5.6.170.0430.07020.71
5.6.160.0100.08720.39
5.6.150.0030.04318.24
5.6.140.0070.07318.23
5.6.130.0170.06718.11
5.6.120.0030.04720.80
5.6.110.0030.08321.11
5.6.100.0130.07720.98
5.6.90.0230.07321.01
5.6.80.0170.07020.53
5.5.350.0200.07020.39
5.5.340.0030.04018.07
5.5.330.0170.07320.30
5.5.320.0230.04720.36
5.5.310.0230.04020.35
5.5.300.0100.07318.04
5.5.290.0070.05017.92
5.5.280.0070.04320.85
5.5.270.0070.06020.93
5.5.260.0200.07020.93
5.5.250.0070.08720.68
5.5.240.2200.03720.15
5.4.450.0100.04319.53
5.4.440.1200.07019.47
5.4.430.1100.04719.47
5.4.420.0670.00019.39
5.4.410.0670.00019.45
5.4.400.0900.00019.22
5.4.390.0830.00019.26
5.4.380.0470.04718.64
5.4.370.0330.05018.78
5.4.360.0270.05718.61
5.4.350.0270.07018.57
5.4.340.0400.06018.82
5.4.320.0090.03412.51
5.4.310.0070.03712.50
5.4.300.0080.03912.50
5.4.290.0050.05212.50
5.4.280.0100.03612.39
5.4.270.0080.03612.40
5.4.260.0090.04112.40
5.4.250.0090.03412.39
5.4.240.0070.04312.39
5.4.230.0060.04112.39
5.4.220.0120.03512.39
5.4.210.0100.04412.39
5.4.200.0080.04112.39
5.4.190.0070.03912.38
5.4.180.0100.03612.39
5.4.170.0070.03712.39
5.4.160.0070.04712.39
5.4.150.0060.04812.39
5.4.140.0100.04312.07
5.4.130.0080.04212.06
5.4.120.0120.04812.02
5.4.110.0070.04112.01
5.4.100.0090.03812.01
5.4.90.0100.04712.01
5.4.80.0060.04112.02
5.4.70.0050.03712.00
5.4.60.0060.03612.01
5.4.50.0080.03412.01
5.4.40.0080.03311.99
5.4.30.0080.03412.00
5.4.20.0080.03512.00
5.4.10.0100.03611.99
5.4.00.0060.03711.48
5.3.290.0060.04312.80
5.3.280.0070.04312.70
5.3.270.0080.03812.72
5.3.260.0130.03612.72
5.3.250.0060.04712.72
5.3.240.0080.03512.72
5.3.230.0040.04112.71
5.3.220.0060.04512.68
5.3.210.0040.04912.68
5.3.200.0070.04312.68
5.3.190.0090.04112.68
5.3.180.0070.04012.67
5.3.170.0090.03612.67
5.3.160.0090.04612.67
5.3.150.0070.03612.68
5.3.140.0080.03512.66
5.3.130.0060.04012.66
5.3.120.0060.04212.66
5.3.110.0050.05112.66
5.3.100.0100.04912.13
5.3.90.0170.04212.11
5.3.80.0090.04812.09
5.3.70.0070.03812.09
5.3.60.0090.03312.08
5.3.50.0080.04012.03
5.3.40.0070.03812.03
5.3.30.0030.03711.99
5.3.20.0060.03511.77
5.3.10.0050.03511.73
5.3.00.0080.04011.71
5.2.170.0070.0319.22
5.2.160.0070.0269.22
5.2.150.0050.0339.22
5.2.140.0060.0299.22
5.2.130.0040.0299.18
5.2.120.0090.0249.18
5.2.110.0040.0309.18
5.2.100.0060.0279.18
5.2.90.0060.0279.18
5.2.80.0050.0299.18
5.2.70.0030.0309.18
5.2.60.0030.0309.13
5.2.50.0050.0299.10
5.2.40.0020.0329.08
5.2.30.0030.0319.05
5.2.20.0030.0299.04
5.2.10.0020.0308.95
5.2.00.0060.0308.82
5.1.60.0060.0228.09
5.1.50.0060.0228.09
5.1.40.0020.0268.07
5.1.30.0040.0268.42
5.1.20.0020.0288.45
5.1.10.0020.0278.17
5.1.00.0060.0248.16
5.0.50.0050.0226.64
5.0.40.0060.0176.50
5.0.30.0040.0326.31
5.0.20.0020.0216.28
5.0.10.0020.0276.26
5.0.00.0010.0376.25
4.4.90.0010.0174.78
4.4.80.0030.0154.75
4.4.70.0020.0174.75
4.4.60.0040.0144.75
4.4.50.0030.0164.77
4.4.40.0000.0274.70
4.4.30.0020.0164.76
4.4.20.0050.0144.84
4.4.10.0010.0174.85
4.4.00.0020.0264.76
4.3.110.0040.0144.67
4.3.100.0030.0144.66
4.3.90.0020.0164.64
4.3.80.0020.0264.58
4.3.70.0050.0124.63
4.3.60.0030.0144.63
4.3.50.0020.0164.62
4.3.40.0060.0204.54
4.3.30.0020.0173.30
4.3.20.0030.0153.28
4.3.10.0030.0153.23
4.3.00.0070.0134.50

preferences:
40.49 ms | 401 KiB | 5 Q