Since PHP 5.6 , a list of variables can be specified using the ... operator.
function do_something($first, ...$all_the_others) { var_dump($first); var_dump($all_the_others); } do_something('this goes in first', 2, 3, 4, 5);
As you can see, the operator ... collects a list of variable arguments in an array.
If you need to pass variable arguments to another function, ... might still help you.
function do_something($first, ...$all_the_others) { do_something_else($first, ...$all_the_others);
Since PHP 7 , a list of variable arguments can be forced to all of the same type.
function do_something($first, int ...$all_the_others) { }
Daniele orlando
source share