What are some best practices for iterating through a multidimensional array in PHP using foreach?

When iterating through a multidimensional array in PHP using foreach, it's important to remember that each element in the array may itself be an array. To properly iterate through all levels of the multidimensional array, you can use nested foreach loops. This allows you to access each element at every level of the array structure.

$multiArray = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
];

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