function f(x, y, z) { }
var args = [0, 1, 2];
f(...args); // <= Like this
Is there a equivalent of "js ...array
decomposition" for php?
(PS: I have already search on google with keyword like : "php array decomposition" but no luck)
function f(x, y, z) { }
var args = [0, 1, 2];
f(...args); // <= Like this
Is there a equivalent of "js ...array
decomposition" for php?
(PS: I have already search on google with keyword like : "php array decomposition" but no luck)
It is called spread operator and it is available starting PHP 7.4
You can find more details about it here.
However, what you are doing here: f(...args)
can be achieved using the Splat Operator which was introduced in PHP 5.6.
You can see more details here