I am trying to pass array to a method and I want the method use array's values as arguments.
I posted a similar question on How to assign arrays to functions arguments? thread but I am actually working on the class method here.
if (method_exists($testInstance, $method)){
$a=array {'1'=>'aru1', '2'=>'arg2'} //could have more than 2. it's dynamic
call_user_func_array($testInstance->$method(), $a); //this won't work.
}
Any thoughts? Thank a lot!
callbable: php.net/manual/en/language.types.callable.php/* Call the $foo->bar() method with 2 arguments*/ $foo = new foo; call_user_func_array(array($foo, "bar"), array("three", "four"));. Also this has been asked before and this is the answer: stackoverflow.com/a/745112/218196. Why do you think the method must be static?