tags:

views:

82

answers:

1

In PHP, is there a way to send a function's arguments straight to another function without having to specify them one by one? Is there a way to expand func_get_arg() so that the other function receives the individual arguments and not just a single array?

I'd like to send the arguments from foo() straight to bar() like so:

function foo($arg1, $arg2, $arg3)
{
  $args = expand_args(func_get_arg());
  bar($args);
}
+5  A: 

yes.

function foo($arg1, $arg2, $arg3)
{
 $args = func_get_arg();

 call_user_func_array("bar",$args);

}
Byron Whitlock