How can nested foreach loops be used to iterate through a multidimensional associative array in PHP?

Nested foreach loops can be used to iterate through a multidimensional associative array in PHP by using one foreach loop to iterate over the outer array and another nested foreach loop to iterate over the inner arrays. This allows you to access each key-value pair in the nested arrays within the outer array.

$multiArray = array(
    'key1' => array('innerKey1' => 'value1', 'innerKey2' => 'value2'),
    'key2' => array('innerKey1' => 'value3', 'innerKey2' => 'value4')
);

foreach ($multiArray as $key => $innerArray) {
    echo "Outer Key: $key\n";
    foreach ($innerArray as $innerKey => $value) {
        echo "Inner Key: $innerKey, Value: $value\n";
    }
}