Goal
I would like to write a function with variable number of parameters (using ...
) that calls another function with the same arguments and a new one at the end. Order is important! The example below is just for demonstration.
What I tried
function foo(...$params) { $extraVariable = 6; var_dump(...$params, $extraVariable);}foo(2, 4, 1, 4);
Problem
When I run it, I get the following error message:
PHP Fatal error: Cannot use positional argument after argument unpacking in /home/user/main.php on line 3
How can I achieve my goal?