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' => [4,5,6], '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.0110.00418.30
8.3.50.0150.00322.06
8.3.40.0040.01118.89
8.3.30.0110.00719.09
8.3.20.0000.00720.29
8.3.10.0060.00320.52
8.3.00.0040.00419.23
8.2.180.0070.01116.50
8.2.170.0030.01022.96
8.2.160.0080.00820.52
8.2.150.0000.00924.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0000.00822.29
8.2.110.0090.00020.47
8.2.100.0070.00418.16
8.2.90.0000.00819.23
8.2.80.0050.00317.97
8.2.70.0080.00017.63
8.2.60.0060.00317.93
8.2.50.0080.00018.07
8.2.40.0050.00318.34
8.2.30.0060.00319.14
8.2.20.0090.00017.64
8.2.10.0000.00818.22
8.2.00.0040.00417.68
8.1.280.0070.01325.92
8.1.270.0040.00422.14
8.1.260.0080.00026.35
8.1.250.0030.00528.09
8.1.240.0090.00023.79
8.1.230.0100.00019.05
8.1.220.0000.00817.79
8.1.210.0040.00418.77
8.1.200.0040.00417.48
8.1.190.0050.00317.35
8.1.180.0000.00818.10
8.1.170.0060.00618.32
8.1.160.0040.00421.92
8.1.150.0040.00418.93
8.1.140.0000.00717.47
8.1.130.0030.00317.91
8.1.120.0000.00717.36
8.1.110.0000.00717.38
8.1.100.0050.00317.48
8.1.90.0080.00017.37
8.1.80.0000.00717.37
8.1.70.0000.00717.44
8.1.60.0040.00417.62
8.1.50.0040.00417.46
8.1.40.0040.00417.53
8.1.30.0030.00617.53
8.1.20.0000.00817.63
8.1.10.0000.00717.43
8.1.00.0090.00017.36
8.0.300.0040.00418.77
8.0.290.0000.00816.63
8.0.280.0030.00318.33
8.0.270.0040.00417.21
8.0.260.0000.00817.25
8.0.250.0030.00316.96
8.0.240.0000.00816.88
8.0.230.0000.00716.84
8.0.220.0070.00016.88
8.0.210.0000.00716.92
8.0.200.0030.00716.98
8.0.190.0000.00716.97
8.0.180.0000.00816.98
8.0.170.0040.00416.97
8.0.160.0000.00716.86
8.0.150.0000.00716.77
8.0.140.0080.00416.74
8.0.130.0030.00313.35
8.0.120.0050.00316.74
8.0.110.0070.00016.79
8.0.100.0000.00716.88
8.0.90.0000.00816.80
8.0.80.0110.00816.88
8.0.70.0040.00416.78
8.0.60.0020.00516.80
8.0.50.0080.00016.93
8.0.30.0120.00817.23
8.0.20.0070.01317.40
8.0.10.0000.00716.94
8.0.00.0100.00916.78
7.4.330.0020.00215.06
7.4.320.0060.00016.61
7.4.300.0030.00316.46
7.4.290.0030.00316.49
7.4.280.0040.00416.51
7.4.270.0000.00616.47
7.4.260.0070.00016.59
7.4.250.0040.00416.38
7.4.240.0020.00616.57
7.4.230.0000.00716.33
7.4.220.0110.01816.54
7.4.210.0110.00316.69
7.4.200.0000.00716.47
7.4.160.0170.00016.59
7.4.150.0130.00817.40
7.4.140.0150.00217.86
7.4.130.0110.00616.53
7.4.120.0110.00616.51
7.4.110.0060.01016.54
7.4.100.0110.00816.47
7.4.90.0080.00916.41
7.4.80.0070.01119.37
7.4.70.0160.00016.73
7.4.60.0070.00916.38
7.4.50.0040.00416.52
7.4.40.0060.00916.52
7.4.30.0080.00816.29
7.4.10.0120.00514.81
7.4.00.0090.00714.87
7.3.330.0020.00213.24
7.3.320.0000.00513.45
7.3.310.0070.00016.25
7.3.300.0030.00316.23
7.3.290.0030.01116.31
7.3.280.0090.00516.37
7.3.270.0140.00317.40
7.3.260.0150.00416.61
7.3.250.0130.01016.39
7.3.240.0130.00316.34
7.3.230.0120.00416.59
7.3.210.0060.01216.48
7.3.200.0200.00319.39
7.3.190.0140.00416.62
7.3.180.0060.01016.43
7.3.170.0120.00416.43
7.3.160.0070.01316.48
7.3.130.0060.01314.91
7.3.120.0090.00915.00
7.3.110.0050.01114.88
7.3.100.0040.01214.79
7.3.90.0090.00714.70
7.3.80.0090.00514.79
7.3.70.0050.01014.79
7.3.60.0090.00314.83
7.3.50.0060.00714.82
7.3.40.0040.00714.86
7.3.30.0060.00614.74
7.3.20.0040.00916.66
7.3.10.0060.00916.66
7.3.00.0070.00516.60
7.2.330.0070.01016.66
7.2.320.0070.01416.56
7.2.310.0060.01316.31
7.2.300.0170.00316.41
7.2.290.0030.01316.35
7.2.260.0090.00815.04
7.2.250.0070.01215.11
7.2.240.0040.01215.15
7.2.230.0110.00414.93
7.2.220.0030.01114.96
7.2.210.0080.00515.11
7.2.200.0080.00615.10
7.2.190.0040.01014.90
7.2.180.0060.00715.05
7.2.170.0040.00914.84
7.2.160.0080.00314.95
7.2.150.0060.00916.76
7.2.140.0070.00516.99
7.2.130.0070.00817.08
7.2.120.0090.00516.76
7.2.110.0000.01216.84
7.2.100.0100.00616.80
7.2.90.0050.00716.95
7.2.80.0110.00517.08
7.2.70.0040.01016.93
7.2.60.0090.00516.98
7.2.50.0080.00617.02
7.2.40.0120.00516.79
7.2.30.0110.00316.98
7.2.20.0090.00616.94
7.2.10.0030.01216.85
7.2.00.0090.00616.88
7.1.330.0080.00715.91
7.1.320.0090.00515.79
7.1.310.0040.00915.69
7.1.300.0070.00615.79
7.1.290.0050.00315.76
7.1.280.0060.00515.84
7.1.270.0050.00615.81
7.1.260.0070.00615.95
7.1.250.0060.00815.63
7.1.240.0060.00415.84
7.1.230.0050.00815.89
7.1.220.0030.00815.60
7.1.210.0050.01115.88
7.1.200.0040.01015.75
7.1.190.0060.00515.82
7.1.180.0020.01115.82
7.1.170.0020.00815.78
7.1.160.0080.00715.83
7.1.150.0020.00615.78
7.1.140.0000.01115.72
7.1.130.0050.00815.54
7.1.120.0090.00415.79
7.1.110.0040.00415.67
7.1.100.0070.00715.73
7.1.90.0020.01215.77
7.1.80.0080.00515.80
7.1.70.0040.00616.29
7.1.60.0060.00716.12
7.1.50.0090.00816.02
7.1.40.0070.00715.82
7.1.30.0070.00215.85
7.1.20.0070.00515.52
7.1.10.0060.00615.87
7.1.00.0020.03317.92
7.0.330.0040.00915.31
7.0.320.0070.00815.42
7.0.310.0050.00615.41
7.0.300.0050.00815.35
7.0.290.0080.00615.44
7.0.280.0050.00815.48
7.0.270.0080.00915.51
7.0.260.0050.00915.27
7.0.250.0030.00815.46
7.0.240.0040.01115.50
7.0.230.0110.00515.27
7.0.220.0080.00315.60
7.0.210.0050.00615.39
7.0.200.0060.01115.76
7.0.190.0000.01015.37
7.0.180.0060.00515.33
7.0.170.0020.01015.48
7.0.160.0050.01115.25
7.0.150.0060.00615.56
7.0.140.0020.03417.64
7.0.130.0090.00515.38
7.0.120.0020.01015.60
7.0.110.0070.00515.29
7.0.100.0050.01115.37
7.0.90.0080.00315.41
7.0.80.0120.00115.35
7.0.70.0050.00615.35
7.0.60.0070.01916.94
7.0.50.0060.03316.35
7.0.40.0040.03115.65
7.0.30.0150.02115.69
7.0.20.0130.03315.59
7.0.10.0070.02815.54
7.0.00.0040.03615.79
5.6.400.0070.00214.44
5.6.390.0020.01214.48
5.6.380.0060.00614.64
5.6.370.0070.01014.42
5.6.360.0100.00314.35
5.6.350.0020.01114.64
5.6.340.0030.00914.61
5.6.330.0090.00514.38
5.6.320.0020.01114.33
5.6.310.0070.00814.50
5.6.300.0090.00514.56
5.6.290.0050.01214.44
5.6.280.0020.03316.79
5.6.270.0060.00314.21
5.6.260.0090.00314.54
5.6.250.0000.00914.62
5.6.240.0060.00914.34
5.6.230.0070.00714.46
5.6.220.0050.00814.42
5.6.210.0060.03016.39
5.6.200.0080.03415.54
5.6.190.0120.02916.49
5.6.180.1080.02116.32
5.6.170.0100.02916.28
5.6.160.0090.02616.31
5.6.150.0070.01715.58
5.6.140.0080.03015.71
5.6.130.0090.03015.64
5.6.120.0080.01716.54
5.6.110.0040.02316.53
5.6.100.0090.02816.61
5.6.90.0050.02916.58
5.6.80.0070.03116.35
5.6.70.0150.02816.24
5.6.60.0050.00614.30
5.6.50.0070.00714.48
5.6.40.0090.00614.44
5.6.30.0060.01014.17
5.6.20.0030.01314.27
5.6.10.0050.00914.34
5.6.00.0040.00914.42
5.5.380.0070.00714.49
5.5.370.0050.00914.28
5.5.360.0060.00814.46
5.5.350.0130.02516.32
5.5.340.0060.03115.57
5.5.330.0080.03316.27
5.5.320.0130.02016.13
5.5.310.0100.01916.31
5.5.300.0070.01515.63
5.5.290.0040.03415.63
5.5.280.0090.03016.51
5.5.270.0100.03016.59
5.5.260.0070.03116.45
5.5.250.0050.03116.47
5.5.240.0110.03216.15
5.5.230.0050.01014.21
5.5.220.0050.01014.10
5.5.210.0060.00614.38
5.5.200.0050.00814.42
5.5.190.0070.00714.24
5.5.180.0080.00814.39
5.5.170.0090.00514.39
5.5.160.0050.00914.22
5.5.150.0030.01014.32
5.5.140.0050.00714.44
5.5.130.0070.00514.36
5.5.120.0030.01014.45
5.5.110.0070.00514.22
5.5.100.0040.00914.16
5.5.90.0080.00514.13
5.5.80.0050.00714.24
5.5.70.0100.00314.28
5.5.60.0080.00714.25
5.5.50.0060.01014.34
5.5.40.0080.00614.13
5.5.30.0030.01014.27
5.5.20.0070.00714.17
5.5.10.0010.01114.19
5.5.00.0000.01314.26
5.4.450.0340.03013.95
5.4.440.0390.02214.05
5.4.430.0380.02113.96
5.4.420.0250.00513.86
5.4.410.0260.00313.99
5.4.400.0220.00513.73
5.4.390.0240.00513.76
5.4.380.0130.02313.55
5.4.370.0100.02513.71
5.4.360.0100.02413.55
5.4.350.0120.02213.60
5.4.340.0120.02313.64
5.4.330.0070.00311.18
5.4.320.0060.01511.62
5.4.310.0060.01411.59
5.4.300.0060.01611.47
5.4.290.0050.01711.61
5.4.280.0070.01411.45
5.4.270.0050.01711.53
5.4.260.0060.01711.52
5.4.250.0040.01711.56
5.4.240.0040.01911.53
5.4.230.0070.01511.48
5.4.220.0050.01911.47
5.4.210.0060.01611.65
5.4.200.0050.01611.46
5.4.190.0090.01511.56
5.4.180.0070.02011.45
5.4.170.0040.01811.56
5.4.160.0070.01611.54
5.4.150.0060.01611.54
5.4.140.0070.01511.48
5.4.130.0040.01611.43
5.4.120.0060.01411.27
5.4.110.0050.01511.45
5.4.100.0060.01411.47
5.4.90.0040.01811.37
5.4.80.0070.01411.39
5.4.70.0080.02011.39
5.4.60.0080.01611.42
5.4.50.0030.01511.39
5.4.40.0060.01511.43
5.4.30.0060.01711.34
5.4.20.0040.01911.38
5.4.10.0070.01711.44
5.4.00.0060.01911.21
5.3.290.0100.05112.80
5.3.280.0060.03912.71
5.3.270.0070.03712.72
5.3.260.0040.04012.72
5.3.250.0060.03612.72
5.3.240.0060.03612.72
5.3.230.0050.03712.71
5.3.220.0060.03612.68
5.3.210.0090.03512.68
5.3.200.0050.03612.68
5.3.190.0070.03612.68
5.3.180.0080.03912.68
5.3.170.0030.03912.67
5.3.160.0080.03612.68
5.3.150.0030.04012.68
5.3.140.0060.03712.66
5.3.130.0080.03712.66
5.3.120.0070.03712.66
5.3.110.0070.03812.66
5.3.100.0070.03612.13
5.3.90.0070.03612.11
5.3.80.0060.03612.09
5.3.70.0030.03812.09
5.3.60.0080.03412.08
5.3.50.0050.03612.02
5.3.40.0050.03712.03
5.3.30.0060.03611.99
5.3.20.0110.02911.77
5.3.10.0090.03211.73
5.3.00.0060.03711.72
5.2.170.0030.0329.21
5.2.160.0030.0309.22
5.2.150.0040.0319.22
5.2.140.0080.0279.22
5.2.130.0040.0299.18
5.2.120.0020.0329.18
5.2.110.0070.0309.19
5.2.100.0030.0359.18
5.2.90.0100.0279.18
5.2.80.0040.0319.18
5.2.70.0050.0309.18
5.2.60.0080.0269.13
5.2.50.0080.0269.10
5.2.40.0050.0289.07
5.2.30.0040.0299.05
5.2.20.0050.0289.04
5.2.10.0070.0298.95
5.2.00.0050.0298.81
5.1.60.0080.0208.09
5.1.50.0040.0268.09
5.1.40.0020.0268.07
5.1.30.0050.0338.42
5.1.20.0040.0278.44
5.1.10.0040.0358.16
5.1.00.0080.0358.17
5.0.50.0030.0216.64
5.0.40.0030.0206.50
5.0.30.0040.0306.31
5.0.20.0070.0166.28
5.0.10.0030.0206.25
5.0.00.0010.0336.25
4.4.90.0020.0164.78
4.4.80.0030.0154.75
4.4.70.0020.0164.75
4.4.60.0030.0154.76
4.4.50.0020.0164.77
4.4.40.0030.0254.71
4.4.30.0040.0134.76
4.4.20.0030.0174.84
4.4.10.0030.0154.85
4.4.00.0060.0254.76
4.3.110.0020.0164.66
4.3.100.0030.0154.66
4.3.90.0020.0154.64
4.3.80.0030.0244.58
4.3.70.0030.0154.63
4.3.60.0030.0184.63
4.3.50.0020.0164.63
4.3.40.0020.0254.54
4.3.30.0000.0193.30
4.3.20.0030.0153.29
4.3.10.0040.0183.23
4.3.00.0130.0307.18

preferences:
51.6 ms | 401 KiB | 5 Q