What are some common pitfalls when iterating through multidimensional arrays in PHP?

One common pitfall when iterating through multidimensional arrays in PHP is not properly accessing the inner arrays within the loop. To avoid this, you can use nested loops to iterate through each level of the multidimensional array.

// Example of iterating through a multidimensional array using nested loops
$multiArray = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
];

foreach ($multiArray as $innerArray) {
    foreach ($innerArray as $value) {
        echo $value . " ";
    }
    echo "\n";
}