[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
The best way will be using array_diff http://php.net/manual/en/function.array-diff.php
array_diff
$arr1 = [2,5,3]; $arr2 = [5,2,3]; $isEqual = array_diff($arr1,$arr2) === array_diff($arr2,$arr1);