In some MVC platforms, a controller method accepts an URL's contents as forward-slash separated list of elements, received as parameters, e.g.
site.com/controller/method/var1/var2
has associated controller:
class Controller
function method(var1, var2){
}
}
But how can I achieve this coding? I wish to start with an array and send a parameterized list to a function, i.e.
$args = array("one"=>"cheese","two"=>"eggs");
php_function("myfunction",$args);
Within myfunction
, I would have
function myfunction($one, $two){
}
I know about func_get_args
for accepting an unknown number of arguments. user_call_func
is useful except
user_call_func("myfunction",$args);
...results in the first parameter containing an array of arguments, no difference to func_get_args
called from within the function.
extract
doesn't work either as I need to receive the array as a variable inside the function.