2 回答
TA贡献1772条经验 获得超8个赞
array_push($categoryArray, array(
"label" => "Lundra"
),array(
"label" => "Ghargoda"
),array(
"label" => "Shankargarh"
),array(
"label" => "Pratappur"
),array(
"label" => "Charama"
)
);
这将为您提供所需的输出
TA贡献2065条经验 获得超13个赞
您面临的主要问题是数组是用键构建的。
例如数字
1 => First,
2 => Second,
...
例如有名字
first_entry => First,
second_entry => Second,
...
当您在数组中定义多个条目时,它们会相互覆盖。要解决此问题,您必须在主数组中为每个项目定义一个数组。
array_push($categoryArray, array(
array("label" => "Lundra"),
array("label" => "Ghargoda"),
array("label" => "Shankargarh"),
array("label" => "Pratappur"),
array("label" => "Charama)"
)
);
这样结果就会是这样的 Array ( [0] => Array ( [label] => Jan ) [1] => Array ( [label] => Feb ) [2] => Array ( [label] => Mar ) [3] => Array ( [label] => Apr ) [4] => Array ( [label] => May ) [5] => Array ( [label] => Jun ))。
- 2 回答
- 0 关注
- 103 浏览
添加回答
举报