What are some potential pitfalls when using "array_diff" to compare arrays in PHP?

One potential pitfall when using "array_diff" to compare arrays in PHP is that it only compares values and not keys. If you also want to compare keys, you will need to use "array_diff_assoc" instead. To solve this issue, you can use "array_diff_assoc" to compare both keys and values of the arrays.

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

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

print_r($diff);