views:

1483

answers:

2

I seem to remember that in PHP there is a way to pass an array as a list of arguments for a function, dereferencing the array into the standard func($arg1, $arg2) manner. But now I'm lost on how to do it. I recall the manner of passing by reference, how to "glob" incoming parameters ... but not how to de-list the array into a list of arguments.

It may be as simple as func(&$myArgs), but I'm pretty sure that isn't it. But, sadly, the php.net manual hasn't divulged anything so far. Not that I've had to use this particular feature for the last year or so.

+16  A: 

http://www.php.net/manual/en/function.call-user-func-array.php

call_user_func_array('func',$myArgs);
vartec
I could've sworn that it was also a non-function, like a prefix character or something. Thanks.
The Wicked Flea
It is, but not in PHP. In Python ;-)
vartec
But I don't know Python! I must be accidentally psychic... :D
The Wicked Flea
+3  A: 

Also note that if you want to apply an instance method to an array, you need to pass the function as:

call_user_func_array(array($instance, "ClassName"), $myArgs);
Jeff Ober