What are some potential pitfalls when working with arrays in PHP?

One potential pitfall when working with arrays in PHP is trying to access an element that does not exist, which can result in a "Undefined offset" notice or error. To avoid this issue, you can use the isset() function to check if the element exists before trying to access it.

$array = [1, 2, 3, 4, 5];

if(isset($array[3])) {
    echo $array[3]; // Output: 4
} else {
    echo "Element does not exist";
}