3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); /** * https://stackoverflow.com/a/68884808/367456 */ $arr1 = [ "databases" => [ 0 => [ "id" => 1, "name" => "DB1", "slug" => "db1", "url" => "https://www.db1.org", ], ], ]; $arr2 = [ "databases" => [ 0 => [ "id" => 5, "name" => "DB2", "slug" => "db2", "url" => "https://www.db2.com", ], ], ]; /** * recursively go over two (optional) arrays old and new * while merging them. * * array values are then taken as: * * ['old' => $old, 'new' => $new]. * * @param array|null $old * @param array|null $new * @return array */ function old_and_new(array $old = null, array $new = null): array { $pair = get_defined_vars(); $map = static fn(callable $map, array $arrays): array => in_array(true, array_map('is_array', $arrays), true) && ($parameter = array_combine($k = array_keys($arrays), $k)) && ($keys = array_keys(array_flip(array_merge(...array_values(array_map('array_keys', array_filter($arrays, 'is_array')))))) ) ? array_map( static fn($key) => $map($map, array_map(static fn($p) => $arrays[$p][$key] ?? null, $parameter)), array_combine($keys, $keys) ) : $arrays; return $map($map, $pair); } print_r(old_and_new(new: $arr2));

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.140.0130.00817.91
8.4.130.0100.01117.75
8.4.120.0050.00422.28
8.4.110.0110.00918.66
8.4.100.0110.00918.73
8.4.90.0120.00918.68
8.4.80.0050.00419.72
8.4.70.0120.00817.91
8.4.60.0090.00720.45
8.4.50.0110.00820.63
8.4.40.0040.00417.89
8.4.30.0100.01020.39
8.4.20.0150.00619.69
8.4.10.0030.00619.71
8.3.270.0160.00316.88
8.3.260.0130.00616.72
8.3.250.0130.00619.02
8.3.240.0090.00316.69
8.3.230.0050.00416.64
8.3.220.0100.00916.92
8.3.210.0090.00716.80
8.3.200.0120.00816.80
8.3.190.0070.00119.09
8.3.180.0100.00918.57
8.3.170.0030.00517.19
8.3.160.0150.00320.18
8.3.150.0110.01116.82
8.3.140.0040.00416.52
8.3.130.0070.01118.24
8.3.120.0060.00319.00
8.3.110.0040.00420.94
8.3.100.0070.00316.73
8.3.90.0160.00326.77
8.3.80.0030.00617.00
8.3.70.0220.00016.63
8.3.60.0120.00616.75
8.3.50.0070.01418.20
8.3.40.0120.00920.75
8.3.30.0140.00718.84
8.3.20.0030.00624.18
8.3.10.0040.00424.66
8.3.00.0070.00026.16
8.2.290.0120.00520.23
8.2.280.0080.00618.70
8.2.270.0130.00716.74
8.2.260.0060.00917.08
8.2.250.0120.00618.35
8.2.240.0080.00817.43
8.2.230.0040.00422.58
8.2.220.0090.00024.06
8.2.210.0080.00026.77
8.2.200.0040.00416.88
8.2.190.0060.00918.18
8.2.180.0090.00625.92
8.2.170.0110.00318.94
8.2.160.0090.00622.96
8.2.150.0040.00425.66
8.2.140.0060.00324.66
8.2.130.0050.00226.16
8.2.120.0050.00221.00
8.2.110.0110.00021.04
8.2.100.0060.00617.91
8.2.90.0030.00517.88
8.2.80.0040.00417.97
8.2.70.0000.00817.75
8.2.60.0060.00317.75
8.2.50.0050.00318.05
8.2.40.0040.00418.16
8.2.30.0030.00617.75
8.2.20.0000.00818.11
8.2.10.0040.00422.33
8.2.00.0050.00319.36
8.1.330.0090.01021.80
8.1.320.0130.00616.34
8.1.310.0100.00018.55
8.1.300.0120.00616.21
8.1.290.0030.00630.84
8.1.280.0030.01725.92
8.1.270.0050.00323.99
8.1.260.0000.00926.35
8.1.250.0070.00028.09
8.1.240.0000.01019.65
8.1.230.0040.00717.83
8.1.220.0040.00417.78
8.1.210.0030.00618.77
8.1.200.0030.00617.35
8.1.190.0060.00317.35
8.1.180.0030.00618.10
8.1.170.0040.00417.62
8.1.160.0000.00718.89
8.1.150.0040.00418.67
8.1.140.0050.00318.85
8.1.130.0050.00317.50
8.1.120.0050.00317.50
8.1.110.0040.00417.50
8.1.100.0030.00617.46
8.1.90.0050.00317.52
8.1.80.0070.00017.40
8.1.70.0020.00517.46
8.1.60.0030.00617.61
8.1.50.0040.00417.57
8.1.40.0000.01017.52
8.1.30.0000.00917.67
8.1.20.0000.00817.70
8.1.10.0040.00417.65
8.1.00.0060.00317.38
8.0.300.0000.00718.77
8.0.290.0080.00016.88
8.0.280.0040.00418.05
8.0.270.0030.00316.87
8.0.260.0060.00016.93
8.0.250.0040.00416.93
8.0.240.0040.00417.04
8.0.230.0000.00716.98
8.0.220.0030.00517.00
8.0.210.0000.00716.99
8.0.200.0050.00316.95
8.0.190.0040.00717.05
8.0.180.0070.00317.07
8.0.170.0030.00616.90
8.0.160.0040.00417.04
8.0.150.0040.00417.00
8.0.140.0080.00016.87
8.0.130.0050.00213.36
8.0.120.0000.00716.96
8.0.110.0000.00716.95
8.0.100.0040.00416.99
8.0.90.0020.00616.93
8.0.80.0040.00417.04
8.0.70.0040.00417.07
8.0.60.0050.00316.97
8.0.50.0050.00316.93
8.0.30.0040.00416.88
8.0.20.0000.00716.96
8.0.10.0040.00416.92
8.0.00.0040.00417.04
7.4.330.0050.00016.95
7.4.320.0030.00616.39
7.4.300.0030.00316.32
7.4.290.0000.00716.40
7.4.280.0040.00416.41
7.4.270.0040.00416.36
7.4.260.0000.00713.26
7.4.250.0000.00716.38
7.4.240.0000.00716.45
7.4.230.0030.00416.47
7.4.220.0000.00716.42
7.4.210.0030.00316.11
7.4.200.0040.00416.45
7.4.190.0040.00416.55
7.4.180.0070.00016.44
7.4.160.0000.00716.25
7.4.150.0070.00016.13
7.4.140.0040.00416.43
7.4.130.0030.00316.22
7.4.120.0070.00016.32
7.4.110.0040.00416.37
7.4.100.0040.00416.29
7.4.90.0040.00416.25
7.4.80.0040.00416.41
7.4.70.0070.00016.28
7.4.60.0070.00016.13
7.4.50.0040.00416.20
7.4.40.0060.00016.02
7.4.30.0040.00416.08
7.4.20.0000.00816.00
7.4.10.0030.00316.14
7.4.00.0030.00316.14
7.3.330.0070.00016.14
7.3.320.0070.00013.20
7.3.310.0030.00316.06
7.3.300.0000.00716.19
7.3.290.0000.00716.16
7.3.280.0030.00516.17
7.3.270.0030.00316.16
7.3.260.0030.00316.08
7.3.250.0000.00616.21
7.3.240.0000.00616.23
7.3.230.0050.00216.20
7.3.220.0060.00016.11
7.3.210.0030.00316.16
7.3.200.0000.00616.14
7.3.190.0070.00016.11
7.3.180.0030.00316.10
7.3.170.0000.00716.10
7.3.160.0030.00316.11
7.3.150.0000.00716.12
7.3.140.0000.00716.16
7.3.130.0000.00715.95
7.3.120.0000.00816.11
7.3.110.0000.00816.07
7.3.100.0000.00816.08
7.3.90.0080.00016.29
7.3.80.0000.00916.07
7.3.70.0000.00816.17
7.3.60.0060.00016.23
7.3.50.0000.00616.21
7.3.40.0030.00316.23
7.3.30.0040.00416.23
7.3.20.0000.00716.18
7.3.10.0000.00716.00
7.3.00.0080.00016.25

preferences:
37.06 ms | 403 KiB | 5 Q