1
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)

Mahefa
  • 418
  • 3
  • 12

1 Answers1

1

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

Cornel Raiu
  • 2,758
  • 3
  • 22
  • 31
  • For Spread Operator for php7.4, yes exactly what i search. But for Splat Operator for older version, it does not do the same thing, it doesn't respond to the question – Mahefa Aug 18 '20 at 10:51