3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input1 = ['hotels' => [ 'hotel' => [ [ "ort" => "rom", "lioc" => "inrom" ], [ "ort" => "paris", "lioc" => "inpsrisd" ], [ "ort" => "berlin", "lioc" => "inberlin" ], [ "ort" => "milano", "lioc" => "inmilano" ], [ "ort" => "paris", "lioc" => "anotherinpsrisd"], [ "ort" => "muc", "lioc" => "inmuc"] ] ]]; $input2 = ['hotels' => [ 'hotel' => [ [ "ort" => "rom", "lioc" => "inrom" ], [ "ort" => "beijing", "lioc" => "wanda" ] ] ]]; function recursiveUnique($input): array { // if the input is not an array, just return the input if (!is_array($input)) { return $input; } // check if the array is a list or an associative array else if (count($input) === 0 || array_keys($input) === range(0, count($input) - 1)) { return array_values(array_unique($input, SORT_REGULAR)); } else { foreach ($input as $key => $value) { $input[$key] = recursiveUnique($value); } return $input; } } var_dump(recursiveUnique(array_merge_recursive($input1, $input2)));

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.130.0050.00417.89
8.4.120.0060.00424.34
8.4.110.0090.01018.77
8.4.100.0060.00417.98
8.4.90.0080.00620.62
8.4.80.0120.00618.75
8.4.70.0100.01018.78
8.4.60.0140.00820.63
8.4.50.0120.00918.76
8.4.40.0050.00317.62
8.4.30.0030.01620.29
8.4.20.0130.00619.89
8.4.10.0130.00619.41
8.3.260.0120.00716.37
8.3.250.0120.00718.69
8.3.240.0110.00917.09
8.3.230.0150.00416.33
8.3.220.0060.00218.86
8.3.210.0110.00616.54
8.3.200.0090.01216.76
8.3.190.0050.00418.81
8.3.180.0090.00519.08
8.3.170.0090.00917.12
8.3.160.0080.00418.40
8.3.150.0030.01416.50
8.3.140.0070.00316.58
8.3.130.0030.00618.36
8.3.120.0060.00320.63
8.3.110.0150.00420.94
8.3.100.0030.00724.06
8.3.90.0000.00826.77
8.3.80.0090.00316.63
8.3.70.0160.00616.63
8.3.60.0100.01016.46
8.3.50.0030.01418.04
8.3.40.0040.01118.94
8.3.30.0090.00618.77
8.3.20.0040.00424.18
8.3.10.0080.00024.66
8.3.00.0040.00426.16
8.2.290.0130.00616.69
8.2.280.0110.00818.45
8.2.270.0080.00818.69
8.2.260.0090.00917.02
8.2.250.0040.01116.78
8.2.240.0060.00318.27
8.2.230.0120.00322.58
8.2.220.0040.00737.54
8.2.210.0040.00426.77
8.2.200.0030.00618.41
8.2.190.0170.00316.75
8.2.180.0090.00625.92
8.2.170.0150.00419.08
8.2.160.0140.00022.96
8.2.150.0080.00025.66
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0050.00326.16
8.2.110.0060.00321.11
8.2.100.0090.00317.84
8.2.90.0040.00417.84
8.2.80.0000.00819.11
8.2.70.0000.00817.63
8.2.60.0030.00518.05
8.2.50.0060.00318.07
8.2.40.0060.00318.19
8.2.30.0000.00918.18
8.2.20.0040.00419.52
8.2.10.0050.00317.77
8.2.00.0040.00419.32
8.1.330.0120.00716.19
8.1.320.0090.01018.24
8.1.310.0140.00318.41
8.1.300.0070.01118.07
8.1.290.0030.00630.84
8.1.280.0040.01125.92
8.1.270.0000.00824.66
8.1.260.0050.00326.35
8.1.250.0030.00528.09
8.1.240.0090.00022.03
8.1.230.0070.00420.89
8.1.220.0000.00817.74
8.1.210.0100.00018.77
8.1.200.0000.00917.35
8.1.190.0060.00317.35
8.1.180.0000.00818.10
8.1.170.0050.00318.52
8.1.160.0090.00018.82
8.1.150.0030.00618.57
8.1.140.0030.00517.47
8.1.130.0040.00418.82
8.1.120.0040.00417.47
8.1.110.0000.00717.41
8.1.100.0000.00717.50
8.1.90.0000.00817.52
8.1.80.0060.00317.50
8.1.70.0070.00017.53
8.1.60.0000.01217.53
8.1.50.0080.00017.43
8.1.40.0030.00617.52
8.1.30.0030.00617.71
8.1.20.0050.00317.56
8.1.10.0030.00617.50
8.1.00.0000.00717.60
8.0.300.0040.00420.00
8.0.290.0000.00816.74
8.0.280.0000.00818.34
8.0.270.0070.00016.85
8.0.260.0030.00318.52
8.0.250.0030.00616.95
8.0.240.0060.00016.94
8.0.230.0000.00717.00
8.0.220.0000.00816.87
8.0.210.0000.00716.96
8.0.200.0000.00816.98
8.0.190.0000.00916.85
8.0.180.0070.00016.90
8.0.170.0060.00316.97
8.0.160.0040.00416.90
8.0.150.0040.00416.86
8.0.140.0040.00416.81
8.0.130.0000.00613.38
8.0.120.0090.00016.96
8.0.110.0060.00316.83
8.0.100.0060.00316.85
8.0.90.0060.00316.79
8.0.80.0040.00416.79
8.0.70.0040.00416.86
8.0.60.0040.00416.80
8.0.50.0090.00016.89
8.0.30.0060.00316.84
8.0.20.0030.00616.94
8.0.10.0040.00416.92
8.0.00.0000.00816.90
7.4.330.0030.00315.55
7.4.320.0000.00616.63
7.4.300.0040.00416.65
7.4.290.0000.00716.40
7.4.280.0070.00016.43
7.4.270.0030.00316.65
7.4.260.0060.00013.30
7.4.250.0030.00516.50
7.4.240.0000.00816.48
7.4.230.0040.00416.60
7.4.220.0000.00816.52
7.4.210.0050.00316.63
7.4.200.0040.00416.50
7.4.190.0000.00816.64
7.4.180.0030.00516.58
7.4.160.0000.00816.48
7.4.150.0050.00216.42
7.4.140.0040.00416.50
7.4.130.0000.00816.36
7.4.120.0050.00316.42
7.4.110.0050.00316.43
7.4.100.0030.00616.44
7.4.90.0050.00316.45
7.4.80.0040.00416.36
7.4.70.0040.00416.48
7.4.60.0000.00816.34
7.4.50.0050.00316.46
7.4.40.0090.00016.44
7.4.30.0000.00816.42
7.4.20.0020.00516.46
7.4.10.0000.00816.45
7.4.00.0060.00316.35
7.3.330.0040.00416.33
7.3.320.0000.00513.39
7.3.310.0050.00316.39
7.3.300.0060.00316.37
7.3.290.0030.00516.20
7.3.280.0030.00616.24
7.3.270.0040.00416.38
7.3.260.0030.00516.31
7.3.250.0040.00416.22
7.3.240.0030.00616.38
7.3.230.0000.00816.25
7.3.220.0000.00816.16
7.3.210.0000.00816.18
7.3.200.0000.00716.20
7.3.190.0030.00316.30
7.3.180.0040.00416.27
7.3.170.0040.00416.15
7.3.160.0040.00416.33
7.3.150.0080.00016.30
7.3.140.0080.00016.28
7.3.130.0040.00416.25
7.3.120.0080.00016.40
7.3.110.0030.00516.21
7.3.100.0070.00016.36
7.3.90.0000.00916.45
7.3.80.0050.00316.17
7.3.70.0030.00316.22
7.3.60.0040.00416.49
7.3.50.0040.00416.31
7.3.40.0040.00416.45
7.3.30.0030.00316.54
7.3.20.0050.00516.28
7.3.10.0090.00016.23
7.3.00.0030.00616.42

preferences:
28.06 ms | 403 KiB | 5 Q