<?php
$students = array(
'2010'=>array('令狐冲',"59"),
'2011'=>array('林平之',"44"),
'2012'=>array('曲洋',"89"),
'2013'=>array('任盈盈',"92")
}
?>我只要序号和成绩??怎么遍历获取
这个问题需要通过数组的索引来访问第二个参数,
<?php
$students = array(
'2010'=>array('令狐冲',"59"),
'2011'=>array('林平之',"44"),
'2012'=>array('曲洋',"89"),
'2013'=>array('任盈盈',"92"),
);
foreach( $students as $key=>$value)
{
echo '学号为'.$key.'的同学成绩为';
echo $value[1];//只要第二项,索引为1。
echo "<br/>";
}
?>