0

I have some difficulties comparing 2 arrays with PHP/Laravel. I want to check if values of those arrays are the same.

For example:

$ar1 = ["asd", "dsa", "aaa"];
$ar2 = ["dsa", "asd"];

Those are not the same, because there is "aaa", but if there is not "aaa" it should say that they have same values.

Any ideas how to do it? I tried with array_intersect and in_array, but nothing works as expected.

  • `$ar1 = ["asd", "dsa", "aaa"]; $ar2 = ["dsa", "asd"]; $result = array_diff($ar1, $ar2);` If count($result) > 0 then the 2 arrays are not the same If count($result) = 0 then 2 arrays are the same – Beater Aug 20 '21 at 14:10

0 Answers0