Is there a built-in function for PHP for me to check whether two arrays contain the same values ( order not important?).
For example, I want a function that returns
You can use array_diff.
$a = array('4','5','2'); $b = array('2','4','5'); if(count(array_diff($a, $b)) == 0) { // arrays contain the same elements } else { // arrays contain different elements }
However, a problem with this approach is that arrays can contain duplicate elements, and still match.