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

0

1 Answer 1

2

With splat operator (...) you can:

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

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

Fiddle.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.