[2,5,3] [5,2,3]
They are equal because they have the same values, but not in the same order. Can I find out that without using a foreach loop
$array1 = array(2,5,3); $array2 = array(5,2,3); $result = array_diff($array1, $array2); if(empty($result)) { echo "Both arrays are equal."; } else { echo "Both arrays are different."; }