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
array_diff looks like an option:
function array_equal($a1, $a2) { return !array_diff($a1, $a2) && !array_diff($a2, $a1); }
or as an oneliner in your code:
if(!array_diff($a1, $a2) && !array_diff($a2, $a1)) doSomething();