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

One common pitfall when working with multidimensional arrays in PHP is incorrectly accessing or modifying values within the nested arrays. To avoid this, make sure to use the correct keys or indexes when accessing elements in the multidimensional array.

// Incorrect way to access nested array value
$multiArray = [
    [1, 2, 3],
    [4, 5, 6]
];

// Incorrect way to access value
echo $multiArray[0][3]; // Notice the incorrect index 3

// Correct way to access nested array value
echo $multiArray[0][2]; // Outputs 3