是的,PHP遍歷操作支持關(guān)聯(lián)數(shù)組??梢允褂胒oreach循環(huán)來(lái)遍歷關(guān)聯(lián)數(shù)組,例如:
$fruits = array("apple" => "red", "banana" => "yellow", "orange" => "orange");
foreach($fruits as $key => $value){
echo "The color of $key is $value <br>";
}
這樣就可以遍歷輸出關(guān)聯(lián)數(shù)組中的鍵和值。