I’m trying to gather all function arguments within a single variable so I can use the single variable instead of entering all arguments into the function.
Below is what I’ve done so far to try to achieve this and it hasn’t been successful.
Variable that stores all variable values together
$bindargs = "$var1, $var2, $var3";
Function which I am trying to pass above variable as 3 separate arguments
function($bindargs);
I want above to run the same as below:
function($var1, $var2, $var3);
2
Answers
Solution: by using array
$bindargs = array('var1'=>$var1,'var2'=>$var2,'var3'=>$var3);
now pass this $bindargs to the function and use like this
Well, I suppose you could do something like this, with an array:
I don’t see why you’d want to. You lose type hinting on your arguments, and named arguments, and this all seems to me like a way just to obfuscate the code and make it difficult for whoever comes after you.