I'm passing an array of methods and parameters to my object. The array can be any size with any number of methods and/or parameters. In between the methods are the parameters.
EDIT: Sorry that this was not clear. The parameters following a method are for THAT method. So in the first example below method1 has two parameters (param1 and param2), method2 has two parameters (param1 and param2) and method3 has one parameter (param).
Here are some examples:
array = ["method1","param1","param2","method2","param1","param2","method3","param"];
array = ["method1","param1","param2","method2","param"];
array = ["method","param"];
I can pull the methods from the array using method_exists but I'm trying to pull the parameters from the array. This is what I've got so far:
// Loop thru $array to find methods
$methods = array();
for($i=0; $i < count($array); $i++) {
if(method_exists($this,$array[$i]) === TRUE) {
$methods[] = $i;
}
}
// Get parameters for methods
// If there is only one method take the remaining array values
// else get the parameters in between the methods
if(count($methods) == 1) {
$parameters = array_slice($array,1,count($array));
} else {
??
}
How can I grab the array values for parameters that match up to the methods when the array values for methods are variable?