I'm pretty stuck here for what to do. I basically want to take all the arguments entered into function one:
func1('hey', 'hey2', 'hey3');
and then run func2 with the same arguments:
func2('hey', 'hey2', 'hey3');
I've tried this:
$arguments = func_get_args();
call_user_func_array(array($this, "func2"), $arguments);
but it doesn't seem to be working correctly? Any ideas?
Turns out the code should be: $arguments = func_get_args(); call_user_func_array(array($this, "func2"), $arguments[0]);
Woops :) Thanks everyone
You can do it simply like this :
$func1 = func1('hey', 'hey2', 'hey3');
func1($hey, $hey2, $hey3){
//func1 stuff here
$func2 = func2($hey, $hey2, $hey3);
}
func2($hey, $hey2, $hey3){
//func2 stuff here
}
Hope this helps :)
function fun1(first,second,third) {
return fun2(first,second,third);
}
Another way is to pass the arguments in an array, like so:
function func1(array $arguments) {
list($hey, $hey2, $hey3, $hey4) = $arguments;
func2($arguments);
}
function func2($arguments) {
print_r($arguments);
}
$arguments = array('hey', 'hey2', 'hey3');
func2($arguments);