给定的数组是
$info=array("sanjay"=>array("male",20),
"ravi"=>array("male",20),
"rahul;"=>array("male",26),
"tina"=>array("male",21),
"sanjna"=>array("female",60)
);
输出应如下所示 -
Name is: Sanjay Sex is: male and Age is: 20
Name is: ravi Sex is: male and Age is: 20
Name is: rahul Sex is: male and Age is: 26
Name is: tina y Sex is: female and Age is: 21
Name is: Sanjna Sex is: female and Age is: 60
答案 0 :(得分:1)
在这种情况下,使用foreach
循环是最佳选择:
foreach($info as $name => $more_info)
{
printf("Name is: %s Sex is: %s and Age is: %d<br />", $name, $more_info[0], $more_info[1]);
}