1

I have multidimensional array in one variable $collection

array:2 [
  0 => array:4 [
    0 => 40
    1 => 39
    2 => 43
    3 => 41
  ]
  1 => array:1 [
    0 => 40
  ]
]

Is there any way to perform array_diff_assoc in one variable instead of this array_diff_assoc($collection[0], $collection[1]).Thank you

M. Badovsky
  • 99
  • 3
  • 10

1 Answers1

2

With splat operator (...) you can:

$a = [
    [40, 39, 43, 41],
    [40],
];

print_r(array_diff_assoc(...$a));

Fiddle.

u_mulder
  • 54,101
  • 5
  • 48
  • 64