What potential pitfalls should PHP developers be aware of when working with arrays?

One potential pitfall for PHP developers when working with arrays is accidentally overwriting array values by using the assignment operator instead of array manipulation functions like array_push or array_merge. To avoid this issue, always use array manipulation functions when adding or removing elements from an array.

// Incorrect way of adding elements to an array
$colors = [];
$colors[0] = 'red'; // This overwrites the empty array

// Correct way of adding elements to an array
$colors = [];
array_push($colors, 'red'); // Use array_push to add elements to an array