📜  打印关联数组 php 代码示例

📅  最后修改于: 2022-03-11 14:54:51.434000             🧑  作者: Mango

代码示例1
//This is the declaration of an associative array.
$animals["firstindex"]="ape";
$animals["secondindex"]="dinosaur";
$animals["thirdindex"]="ahahah";
for(reset($animals);$element=key($animals);next($animals))
{print("$element is $animals[$element]");
}

//Can also be created by using an array function
$fourth=array("January"=>"first","February"=>"second","March"=>"third","April"=>"fourth");
foreach($fourth as $element=>$value)
print("$element is the $value month");