Los argumentos de una función se pueden especificar de forma que esta pueda aceptar cualquier número de argumentos:
<?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]
Si especificas un argumento de longitud variable además de otros, debe ser el último argumento.
<?php
function writeLines($file_handle, ...$lines)
{
put_file_contents($file_handle, implode("\n", $lines));
}
writeLines('file.txt', "a", "b", "c");