php多维数组用法示例

前端之家收集整理的这篇文章主要介绍了php多维数组用法示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PHP多维数组使用范例感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!
这段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

猜你在找的PHP相关文章