Code: Select all
// initial function call
getMethod('getNames', array(23, 33));
public function getMethod($methodName=null, $methodParams=array())
{
// dynamically call the function and pass the parameters
return $members->$methodName(??????????);
}
Code: Select all
public function getNames($ageGreaterThanEqualTo=0, $ageLessThanEqualTo=0)
{
...
Again, the number of parameters in getMethod('getNames', array(23, 33)); (the second parameter array) can vary...so that means I can potentially have something like this also: getMethod('getFemales', array(23, 33, "mary")); (public function getFemales($ageFrom, $ageTo, $firstName)) or getMethod('getMales', array(23, 33, "Jay", "1930")); (public function getMales($ageFrom, $ageTo, $firstName, $yearBorn)). I need to be able to get it to work with any number of parameters depending on the function parameter definition.
So what I need is a way to get the $methodParams and somehow make it so that this line return $members->$methodName(??????????); will end up looking like this dynamically return $members->$methodName($methoParams[0], [1], ... , $methodParams[n-1]);
Is this possible to do without hardcoding? Thank you.