How can foreach loops be used to iterate through multidimensional arrays in PHP?

When iterating through multidimensional arrays in PHP, foreach loops can be used to access each element of the array. To iterate through a multidimensional array, you can nest foreach loops, with each loop iterating over a different dimension of the array. This allows you to access and manipulate the elements of the multidimensional array effectively.

$multiArray = array(
    array(1, 2, 3),
    array(4, 5, 6),
    array(7, 8, 9)
);

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