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

One potential pitfall when working with multidimensional arrays in PHP is accidentally accessing non-existent keys or indices, which can lead to errors or unexpected behavior. To avoid this, it's important to check if the key or index exists before trying to access it.

// Check if key exists before accessing it in a multidimensional array
if(isset($array[$key1][$key2])) {
    // Access the value if the key exists
    $value = $array[$key1][$key2];
} else {
    // Handle the case where the key does not exist
    $value = null;
}