3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface ModifierInterface { public function apply(array $data, string $key): array; } class ArrayHelper { public static function mergeReverse(...$args): array { return self::applyModifiers(self::performMergeReverse(...$args)); } public static function merge(...$args): array { return self::applyModifiers(self::performMerge(...$args)); } private static function performMergeReverse(...$args): array { $res = array_pop($args) ?: []; while (!empty($args)) { foreach (array_pop($args) as $k => $v) { if (is_int($k)) { if (array_key_exists($k, $res) && $res[$k] !== $v) { $res[] = $v; } else { $res[$k] = $v; } } elseif (is_array($v) && isset($res[$k]) && is_array($res[$k])) { $res[$k] = self::performMergeReverse($v, $res[$k]); } elseif (!isset($res[$k])) { $res[$k] = $v; } } } return $res; } private static function performMerge(...$args): array { $res = array_shift($args) ?: []; while (!empty($args)) { foreach (array_shift($args) as $k => $v) { if (is_int($k)) { if (array_key_exists($k, $res) && $res[$k] !== $v) { $res[] = $v; } else { $res[$k] = $v; } } elseif (is_array($v) && isset($res[$k]) && is_array($res[$k])) { $res[$k] = self::performMerge($res[$k], $v); } else { $res[$k] = $v; } } } return $res; } public static function applyModifiers(array $data): array { $modifiers = []; foreach ($data as $k => $v) { if ($v instanceof ModifierInterface) { $modifiers[$k] = $v; unset($data[$k]); } elseif (is_array($v)) { $data[$k] = self::applyModifiers($v); } } foreach ($modifiers as $key => $modifier) { $data = $modifier->apply($data, $key); } return $data; } } $package = [ 'ApplicationStartup::class' => [ ['WebAppInfoCollector::class', 'collect'], ], 'ApplicationShutdown::class' => [ ['WebAppInfoCollector::class', 'collect'], ], 'BeforeRequest::class' => [ ['Debugger::class', 'startup'], ['WebAppInfoCollector::class', 'collect'], ], ]; $app = [ 'ApplicationStartup::class' => [ ['AppStartup::class', 'start'], ], 'ApplicationShutdown::class' => [ ['AppShutdown::class', 'shutdown'], ['WebAppInfoCollector::class', 'collectMainApp'], ], ]; $result = ArrayHelper::merge($package, $app); var_export($result); echo "\n\n"; $resultPop = ArrayHelper::mergeReverse($package, $app); var_export($resultPop);

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.120.0080.00124.19
8.4.110.0100.01022.14
8.4.100.0050.00318.63
8.4.90.0130.00718.73
8.4.80.0030.00518.93
8.4.70.0080.01420.68
8.4.60.0120.01120.67
8.4.50.0090.00718.91
8.4.40.0030.01617.91
8.4.30.0090.00618.59
8.4.20.0160.00318.05
8.4.10.0070.01020.49
8.3.250.0120.00618.82
8.3.240.0100.00917.39
8.3.230.0070.00216.44
8.3.220.0100.00919.05
8.3.210.0100.00918.47
8.3.200.0040.00716.59
8.3.190.0060.00217.27
8.3.180.0090.00818.74
8.3.170.0120.00616.86
8.3.160.0120.00618.45
8.3.150.0150.00316.66
8.3.140.0100.00016.42
8.3.130.0030.00618.35
8.3.120.0050.00318.91
8.3.110.0040.00420.94
8.3.100.0080.00824.06
8.3.90.0060.01226.77
8.3.80.0060.00319.36
8.3.70.0060.01318.43
8.3.60.0040.01116.75
8.3.50.0070.01024.47
8.3.40.0000.01519.17
8.3.30.0070.01118.70
8.3.20.0040.00424.18
8.3.10.0040.00424.66
8.3.00.0000.01026.16
8.2.290.0100.00920.46
8.2.280.0110.00818.60
8.2.270.0070.01318.54
8.2.260.0030.00717.29
8.2.250.0030.00516.62
8.2.240.0070.01317.14
8.2.230.0000.00822.58
8.2.220.0120.00337.54
8.2.210.0000.00826.77
8.2.200.0040.00718.88
8.2.190.0150.00016.63
8.2.180.0110.01125.92
8.2.170.0070.00722.96
8.2.160.0030.01022.96
8.2.150.0040.00425.66
8.2.140.0050.00324.66
8.2.130.0050.00226.16
8.2.120.0040.00426.35
8.2.110.0100.00020.52
8.2.100.0100.00317.84
8.2.90.0030.00617.75
8.2.80.0070.00518.58
8.2.70.0050.00517.63
8.2.60.0000.00817.72
8.2.50.0050.00318.05
8.2.40.0040.00419.88
8.2.30.0030.00518.14
8.2.20.0030.00618.14
8.2.10.0000.00819.31
8.2.00.0050.00219.31
8.1.330.0150.00621.98
8.1.320.0120.01117.93
8.1.310.0070.00018.54
8.1.300.0160.00317.91
8.1.290.0070.00330.84
8.1.280.0170.00325.92
8.1.270.0030.00623.75
8.1.260.0040.00428.09
8.1.250.0070.00328.09
8.1.240.0060.00323.77
8.1.230.0030.00921.04
8.1.220.0030.00618.73
8.1.210.0040.00418.77
8.1.200.0040.00417.63
8.1.190.0040.00417.35
8.1.180.0080.00018.10
8.1.170.0070.00019.09
8.1.160.0050.00318.91
8.1.150.0050.00318.91
8.1.140.0000.00718.92
8.1.130.0000.00720.05
8.1.120.0070.00017.36
8.1.110.0000.00717.45
8.1.100.0060.00317.36
8.1.90.0040.00417.51
8.1.80.0040.00417.49
8.1.70.0030.00317.47
8.1.60.0000.00917.62
8.1.50.0030.00617.54
8.1.40.0030.00617.39
8.1.30.0000.00817.61
8.1.20.0040.00417.68
8.1.10.0000.00817.57
8.1.00.0030.00517.44
8.0.300.0000.00820.21
8.0.290.0050.00316.63
8.0.280.0080.00018.54
8.0.270.0080.00017.92
8.0.260.0040.00420.28
8.0.250.0000.00717.01
8.0.240.0030.00316.87
8.0.230.0000.00717.06
8.0.220.0030.00316.86
8.0.210.0030.00316.89
8.0.200.0000.00716.90
8.0.190.0080.00016.86
8.0.180.0050.00316.96
8.0.170.0000.00816.96
8.0.160.0050.00216.83
8.0.150.0000.00816.73
8.0.140.0040.00416.87
8.0.130.0030.00313.38
8.0.120.0000.00816.86
8.0.110.0040.00416.71
8.0.100.0000.00816.80
8.0.90.0000.00916.93
8.0.80.0060.01116.89
8.0.70.0040.00416.77
8.0.60.0040.00416.78
8.0.50.0070.00016.79
8.0.30.0070.01017.08
8.0.20.0110.00817.18
8.0.10.0050.00316.98
8.0.00.0110.01116.97
7.4.330.0020.00215.55
7.4.320.0030.00316.52
7.4.300.0060.00016.48
7.4.290.0090.00016.58
7.4.280.0000.00816.65
7.4.270.0040.00416.61
7.4.260.0000.00513.29
7.4.250.0030.00616.47
7.4.240.0040.00416.55
7.4.230.0030.00316.46
7.4.220.0020.00516.70
7.4.210.0070.00916.68
7.4.200.0030.00316.50
7.4.130.0090.01016.49
7.4.120.0100.01416.67
7.4.110.0080.01116.48
7.4.100.0070.01416.43
7.4.90.0080.01616.46
7.4.80.0130.00919.39
7.4.70.0100.00716.67
7.4.60.0130.00716.50
7.4.50.0220.00016.35
7.4.40.0110.01516.48
7.4.30.0140.01116.50
7.4.20.0130.01116.22
7.4.10.0110.01116.36
7.4.00.0140.00416.58
7.3.330.0070.00016.43
7.3.320.0060.00013.25
7.3.310.0000.00716.41
7.3.300.0000.00716.43
7.3.290.0060.00916.37
7.3.260.0060.01316.45
7.3.240.0090.01016.57
7.3.230.0160.00616.44
7.3.210.0140.00316.60
7.3.200.0060.00916.38
7.3.190.0130.01016.58
7.3.180.0260.00316.34
7.3.170.0190.00516.27
7.3.160.0220.00616.21
7.3.150.0220.00616.39
7.3.140.0250.00016.55
7.3.130.0170.01216.46
7.3.120.0090.01416.43
7.3.110.0200.00816.48
7.3.100.0170.00416.57
7.3.90.0130.01016.36
7.3.80.0210.00016.34
7.3.70.0090.01316.13
7.3.60.0120.00916.35
7.3.50.0000.02116.33
7.3.40.0230.00416.30
7.3.30.0290.00016.41
7.3.20.0270.00816.48
7.3.10.0130.01816.39
7.3.00.0280.00416.43
7.2.330.0140.01416.55
7.2.310.0170.01016.58
7.2.300.0150.00616.48
7.2.290.0210.00716.58
7.2.280.0160.01316.68
7.2.270.0150.01216.61
7.2.260.0100.01716.34
7.2.250.0160.00816.56
7.2.240.0130.00916.45
7.2.230.0080.01416.59
7.2.220.0200.00516.76
7.2.210.0160.01016.80
7.2.200.0160.00616.52
7.2.190.0160.00616.20
7.2.180.0260.00016.61
7.2.170.0250.00816.75
7.2.160.0210.00616.84
7.2.150.0210.00816.64
7.2.140.0260.00916.72
7.2.130.0300.00016.78
7.2.120.0270.00316.71
7.2.110.0260.00616.66
7.2.100.0240.00616.67
7.2.90.0240.00316.64
7.2.80.0240.00616.58
7.2.70.0150.00916.68
7.2.60.0180.00616.47
7.2.50.0240.00816.45
7.2.40.0200.00316.66
7.2.30.0170.00716.49
7.2.20.0260.00316.65
7.2.10.0160.00916.55
7.2.00.0000.01916.71

preferences:
30.04 ms | 403 KiB | 5 Q