Variadic¶
Three dots, aka ellipsis, is an operator to spread or collect array values.
Applied to an array, it spreads the values of the array as distinct elements.
Used in a function signature, it collects all the values into one array.
<?php
$array = [1, 2, 3];
// same as foo(0, 1,2, 3);
foo(0, ...$array, 4);
function foo($special, ...$others) {
// with the above call
// $special === 0
// $others === [1, 2, 3, 4]
}
?>
See also PHP variadic
Related : Variable Arguments, Array Spread, Ellipsis, Unpacking, Unpacking
Added in PHP 5.6