関数の引数は、いくつでも受け取れるように指定できます。
<?php
function actOnItems(...$items) {
// $items is an array containing 0 or more values
// used to call the function.
}
actOnItems(1, 2, 3, 4); // $items => [1, 2, 3, 4]
ほかの引数と一緒に可変長引数を指定する場合は、それを最後の引数にしなければなりません。
<?php
function writeLines($file_handle, ...$lines)
{
put_file_contents($file_handle, implode("\n", $lines));
}
writeLines('file.txt', "a", "b", "c");