$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
或者如下
$age['Peter']="35";
$age['Ben']="37";
$age['Joe']="43";

类似于python中的dict字典

<?php
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
echo "Peter is " . $age['Peter'] . " years old.";
?>
Peter is 35 years old.

PHP关联数组遍历 key->value

<?php
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");

foreach($age as $x=>$x_value)
{
echo "Key=" . $x . ", Value=" . $x_value;
echo "<br>";
}
?>
Key=Peter, Value=35
Key=Ben, Value=37
Key=Joe, Value=43