How would I go about writing a function in php with an unknown number of parameters, for example
function echoData (parameter1, parameter2,) { //do somet
Just for those who found this thread on Google.
In PHP 5.6 and above you can use ... to specify the unknown number of parameters:
function sum(...$numbers) { $acc = 0; foreach ($numbers as $n) { $acc += $n; } return $acc; } echo sum(1, 2, 3, 4); // 10
$numbers is an array of arguments.
$numbers