php关联数组用法示例

前端之家收集整理的这篇文章主要介绍了php关联数组用法示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PHP关联数组使用范例演示感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!
这段代码演示了PHP数组的强大功能,关联数组的创建和使用,PHP中的关联数组和python中的字典非常类似

/**
 * PHP关联数组使用范例演示
 *
 * @param 
 * @arrange 512-笔记网: jb51.cc
 **/
/* First method to associate create array. */
$salaries = array( 
	 "mohammad" => 2000,"qadir" => 1000,"zara" => 500
	);
echo "Salary of mohammad is ". $salaries['mohammad'] . "<br />";
echo "Salary of qadir is ".  $salaries['qadir']. "<br />";
echo "Salary of zara is ".  $salaries['zara']. "<br />";
/* Second method to create array. */
$salaries['mohammad'] = "high";
$salaries['qadir'] = "medium";
$salaries['zara'] = "low";
echo "Salary of mohammad is ". $salaries['mohammad'] . "<br />";
echo "Salary of qadir is ".  $salaries['qadir']. "<br />";
echo "Salary of zara is ".  $salaries['zara']. "<br />";

/***   来自编程之家 jb51.cc(jb51.cc)   ***/
输出结果如下: Salary of mohammad is 2000 Salary of qadir is 1000 Salary of zara is 500 Salary of mohammad is high Salary of qadir is medium Salary of zara is low

猜你在找的PHP相关文章