array_merge()
and array_merge_recursive()
array_merge() and
array_merge_recursive() can now also be called without
an argument:
var_dump(array_merge());
var_dump(array_merge_recursive());
Executing the code shown above will print the output shown below:
array(0) {
}
array(0) {
}
When array_merge() and
array_merge_recursive() are called without an argument
they return an empty array. This is useful when the spread operator
... is used as ...$arrays may be unpacked
to an empty list in which case array_merge(...$arrays),
for instance, leads to array_merge() being called
without an argument.