What potential issues or pitfalls can arise when comparing arrays in PHP?

When comparing arrays in PHP, potential issues can arise due to the way PHP compares arrays. PHP compares arrays by checking if the arrays have the same key/value pairs in the same order. This can lead to unexpected results if the arrays have the same values but in a different order. To avoid this issue, you can use the `array_diff` function to compare arrays in a way that ignores the order of elements.

$array1 = [1, 2, 3];
$array2 = [3, 1, 2];

if (array_diff($array1, $array2) || array_diff($array2, $array1)) {
    echo "Arrays are not equal";
} else {
    echo "Arrays are equal";
}