编程语言
首页 > 编程语言> > 102-PHP多维数组的元素输出

102-PHP多维数组的元素输出

作者:互联网

<?php
    //定义一个三维数组
    $grade=array('class1'=>array('stu1'=>array('yuwen'=>85,'shuxue'=>95,'yingyu'=>96),
                                 'stu2'=>array('yuwen'=>76,'shuxue'=>89,'yingyu'=>99),
                                 'stu3'=>array('yuwen'=>75,'shuxue'=>99,'yingyu'=>100)),
                 'class2'=>array('stu1'=>array('yuwen'=>99,'shuxue'=>100,'yingyu'=>100)),
                 'class3'=>array(array(80,90,99)));
    //访问数组中的元素
    echo '该年级1班的stu1学生的yuwen成绩为:'.$grade['class1']['stu1']['yuwen'];
    echo '<br />该年级1班的stu3学生的yingyu成绩为:'.$grade['class1']['stu3']['yingyu'];
    echo '<br />该年级2班的stu1学生的shuxue成绩为:'.$grade['class2']['stu1']['shuxue'];
    echo '<br />该年级3班的学生0的成绩1为:'.$grade['class3'][0][1];
?>

 

标签:shuxue,stu1,grade,yuwen,多维,102,array,PHP,yingyu
来源: https://www.cnblogs.com/tianpan2019/p/11001676.html