function foobar($arg1 , $arg2) {
echo $arg1.arg2;
};
is there any way to call it lik开发者_运维百科e this:
$args = 'foo, bar';
foobar($args);
I know I can do this with a array, but my foobar() already have a lot of code calling it with 2 arguments.
Thank you,
mjs
You have to use call_user_func_array for this. Like so:
call_user_func_array('foobar', explode(',', $args));
This would be the same as doing:
foobar('foo', 'bar');
call_user_func_array('foobar', explode(', ', 'foo, bar'));
should do the trick.
精彩评论