I have two functions:
function example($param1, $param2)
{
echo $param1 . $param2;
}
function frutas($fruta1, $fruta2, $fruta3)
{
echo $fruta1 . $fruta2 . $fruta3;
}
I also have a variable that gets the parameters of the functions in the form of an array :
$array = ['param1', 'param2'] // para função example()
or $array = ['fruta1', 'fruta2', 'fruta3'] // para função fruta()
I can manually pass the values this way:
example($array[0], $array[1])
I do not want to pass manually because the frutas
function for example has 3 parameters and not 2. And I would like it to be automatic, passing all arguments. As if it were a foreach
.
Is there a way for me to do this?