I need to pass params (like: 'param1', 'param2', 'param3') to the method... but I have array of params (like: array('param1', 'param2', 'param3')). How to convert array to params?
function foo(array $params) {
    bar(
        // Here should be inserted params not array.
    );
}
                Use the function call_user_func_array.
For example:
call_user_func_array('bar', $params);
                        If you know the param names you could to the following
$params = array(
    'param1' => 'value 1',
    'param2' => 'value 2',
    'param3' => 'value 3',
);
function foo(array $someParams) {
    extract($someParams);  // this will create variables based on the keys
    bar($param1,$param2,$param3);
}
Not sure if this is what you had in mind.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With