There are a few functions with different number of parameters in PHP. I have no idea which function is going to be called, but the function and its parameter is passed to the calling function as array like this
function func1($a,$b){...}
function func2($a){...}
$calls = [func1=>[arg1, arg2], func2=>[arg1]]
I need to call each function with its parameters. I don't know how to pass the parameters as distinct variables. This my code
$func_names = array_keys($calls);
$i = 0;
foreach($calls as $call){
$func_names[$i]($calls[$func_names[$i++]]);
//$func_names[$i]($call); same as above line
}
In each iteration array of arguments of each function is passed to the function not each item of the array separately. How can I solve this problem?
thanks