No Unknown For array_merge()¶
<?php
function foo($x, ...$array) {
print_r($x);
print_r($array);
}
$a = ['w' => 'w', 'x' => 'x'];
foo(...$a);
print_r(array_merge(...$a));
// array_merge() does not accept unknown named parameters
A PHP variadic argument collects all the unused named parameters, along with their key. That way, it is possible to handle them with their name inside the method.
On the other hand, array_merge(), and some cousins, refuse them, and emits a Fatal error. There, it is important to use array_values() to avoid named parameters.
See Also¶
PHP Error Messages¶
PHP Features¶
Last updated: 14 July 2026