I have to arrays and want to check if they have the same values, not matters the order, so I used == operator:
$roles = ['admin', 'manager'];
$needle = ['manager', 'admin'];
$needle == $roles; // false
The problem is that with same values but in different order, the operator evaluates the comparison to false.
How to properly compare two arrays to check if values are the same?
UPDATE
For now, I'm going with array_intersect:
$hasExactRoles = (
(array_intersect($roles, $needle) === $roles) &&
(array_intersect($needle, $roles) === $needle)
);