Use the splat operator to decompress array arguments in the same way as you used in a function:
selectAll($str, ...$arr);
So like this:
function selectAll(string $sql, ...$params) {
print_r(func_get_args());
}
$str = "This is a string";
$arr = ["First Element", "Second Element", 3];
selectAll($str, ...$arr);
Print
Array
(
[0] => This is a string
[1] => First Element
[2] => Second Element
[3] => 3
)
Eval for this.
If you do not use the splat operator in the arguments, you will get like this
source
share