Reputation: 9749
Given the function bar
takes a variable number of arguments. How can foo
be implemented?
function foo($a, $b, $c) {
return bar($a, $b, $c[0], $c[1], $c[2], ..., $c[n]);
}
Upvotes: 0
Views: 41
Reputation: 197775
call_user_func_array
allows you to call a function with an array of parameters. Create the parameter array and call the function:
$parameters = array_merge(array($a, $b), $c);
return call_user_func_array('bar', $parameters);
Upvotes: 1