In short, what I want is a kind of export() function (but not export()), it creates new variables in symbol table and returns the number of created vars.
I’m trying to figure out if it is possible to declare a function
function foo($bar, $baz)
{
var_dump(func_get_args());
}
And after that pass an array so that each value of array would represent param.
Just wondering if it is possible (seems that is not).
I need this for dynamic loading, so number of arguments, size of array may vary – please dont offer to pass it as
foo($arr['bar']);
and so on.
Again, ideal thing solution will look like
foo(array('foo'=>'1', 'bar'=>'2', ..., 'zzz'=>64));
for declaration
function foo($foo, $bar, ..., $zzz) {}
As far as I rememeber in some dynamical languages lists may behave like that (or maybe I’m wrong).
(I want to create dynamically parametrized methods in class and built-in mechanism of controlling functions arguments number, default value and so on is quite good for this, so I could get rid of array params and func_get_args and func_get_num calls in the method body).
Thanks in advance.
You’re looking for call_user_func_array
example: