array(key1 => value1, key2 => value2...)
它返回参数组。可以使用=>运算符为参数指定索引
Sr.No | Parameter & Description |
---|---|
1 |
key(可选) 它指定数字或字符串类型的键。如果未设置,则从0开始生成整数键 |
2 |
value(必需) 链接:https://www.learnfk.comhttps://www.learnfk.com/php/php-function-array.html 来源:LearnFk无涯教程网 它指定值 |
它返回参数组。
<?php $abc=array("a"=>"Dog", "b"=>"Cat", "c"=>"Horse"); print_r($abc); ?>
这将产生以下输出-
Array ( [a] => Dog [b] => Cat [c] => Horse )
下面的示例演示如何创建二维数组,如何为关联数组指定键,以及如何在普通数组中跳过并继续数字索引。
<?php $fruits=array ( "fruits" => array("a" => "orange", "b" => "banana", "c" => "apple"), "numbers" => array(1, 2, 3, 4, 5, 6), "holes" => array("first", 5 => "second", "third") ); print_r($fruits); ?>
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)