这段PHP代码定义了一个二维数组用于存储学生的学科成绩,代码演示了如何定义和使用二维数组
/**
* PHP多维数组使用范例
*
* @param
* @arrange 512-笔记网: www.www.jb51.cc
**/
$marks = array(
"mohammad" => array
(
"physics" => 35,"maths" => 30,"chemistry" => 39
),"qadir" => array
(
"physics" => 30,"maths" => 32,"chemistry" => 29
),"zara" => array
(
"physics" => 31,"maths" => 22,"chemistry" => 39
)
);
/* Accessing multi-dimensional array values */
echo "Marks for mohammad in physics : " ;
echo $marks['mohammad']['physics'] . "<br />";
echo "Marks for qadir in maths : ";
echo $marks['qadir']['maths'] . "<br />";
echo "Marks for zara in chemistry : " ;
echo $marks['zara']['chemistry'] . "<br />";
/*** 来自编程之家 jb51.cc(jb51.cc) ***/
输出结果Marks for mohammad in physics : 35 Marks for qadir in maths : 32 Marks for zara in chemistry : 39 原文链接:https://www.f2er.com/php/528290.html