php关联数组用法示例
内容摘要
这篇文章主要为大家详细介绍了php关联数组用法示例,具有一定的参考价值,可以用来参考一下。
对php关联数组使用范例演示对此感兴趣的朋友,看看idc笔记做的技术笔记!这段代码演
对php关联数组使用范例演示对此感兴趣的朋友,看看idc笔记做的技术笔记!这段代码演
文章正文
这篇文章主要为大家详细介绍了php关联数组用法示例,具有一定的参考价值,可以用来参考一下。
对php关联数组使用范例演示对此感兴趣的朋友,看看idc笔记做的技术笔记!这段代码演示了php数组的强大功能,关联数组的创建和使用,php中的关联数组和python中的字典非常类似
/**
* php关联数组使用范例演示
*
* @param
* @arrange 512-笔记网: www.idcnote.com
**/
/* 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 />";
/*** 来自php教程(www.idcnote.com) ***/
输出结果如下: 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关联数组用法示例的内容就先介绍到这里,更多相关文章的可以留意
代码注释