What are the potential pitfalls of using array_diff for comparing multidimensional arrays in PHP?

When using array_diff to compare multidimensional arrays in PHP, it only compares the values of the arrays and not the keys. This can lead to incorrect results if the keys are important in the comparison. To solve this issue, you can use array_diff_assoc instead, which compares both the keys and values of the arrays.

$array1 = [
    'a' => 1,
    'b' => 2,
    'c' => 3
];

$array2 = [
    'a' => 1,
    'b' => 2,
    'c' => 4
];

$diff = array_diff_assoc($array1, $array2);

print_r($diff);