Not quite sure how to word the title better.
What i need to do, is call a method with call_user_func. The method i'm calling accept several different variables (var1, var2, var3 etc), not an array. The problem is, when calling the function i need to pass the array i have as seperate variables to the method. Let me show you.
Here's my method:
class Test {
public function testing_cronjob($p1, $p2, $p3, $p4, $p5) {
echo 'p1 = ' . $p1 . '<br />';
echo 'p1 = ' . $p2 . '<br />';
echo 'p1 = ' . $p3 . '<br />';
echo 'p1 = ' . $p4 . '<br />';
echo 'p1 = ' . $p5 . '<br />';
}
}
And here's how i currently (try) to call it:
$obj = new Test();
call_user_func(array($obj, 'testing_cronjob'), $params);
The method runs, but it only gets one variable, which is not what i want.
$params look like this:
$params = array(
0 => 'first one',
1 => 'second one',
2 => 'third param!',
3 => 'oh and im fourth!!',
4 => 'im last, fml! :('
)
The way i got myself into this situation, is because i'm creating a cronjob model. It accepts params along with class and method name. It's all stored in a database, and when it runs, i need to be able to send the $params to the method as intended.
I can't rewrite how methods accept variables, because that would be way too much work. I'm going to be calling several (10+) methods from the cronjob, all of which are pretty well used in the application. I'm also not sure how i would re-write it, but if you have any suggestions about that, let me know.
Also, i'm using codeigniter if that matters. If i forgot to mention anything or you want more code, just drop a comment.
Is this possible? Are there any workarounds? Any suggestions are welcome!