一、数组分类
1、索引数组
$cars=array("Volvo","BMW","SAAB");
2、关联数组
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
二、索引数组操作
三、关联数组操作
1、添加元素
方法一:
$rowResult = array(); $rowResult =$rowResult+ array("a"=>"b"); $rowResult =$rowResult+ array("c"=>"b");
结果
{"a":"b","c":"b"}
2、添加数组
方法一:
$result = array(); $rowResult = array(); $rowResult =$rowResult+ array("a"=>"b"); $rowResult =$rowResult+ array("c"=>"b"); array_push($result,$rowResult); array_push($result,$rowResult);
结果:
[{"a":"b","c":"b"},{"a":"b","c":"b"}]
-