向多维php数组添加数据
我有一个输出以下内容的数组:向多维php数组添加数据,php,arrays,Php,Arrays,我有一个输出以下内容的数组: Array ( [0] => Array ( [0] => wordpress ) [1] => Array ( [0] => wordpress [1] => forms ) [2] => Array ( [0] => w
Array
(
[0] => Array
(
[0] => wordpress
)
[1] => Array
(
[0] => wordpress
[1] => forms
)
[2] => Array
(
[0] => wordpress
[1] => galleries
)
[3] => Array
(
[0] => wordpress
[1] => ecommerce
)
[4] => Array
(
[0] => wordpress
[1] => ecommerce
[2] => wp-e-commerce
)
)
如何将项目添加到[0]=>数组中
这是我创建阵列的方式:
$cats = array();
foreach($items as $x=> $item) {
$ex = explode("/",$item['path']);
$cats[] = explode("/",$item['path']);
echo $item['name'].' - '. $item['path'];
echo "<br>";
}
print_r($cats);
$cats=array();
foreach($x=>$item的项目){
$ex=分解(“/”,$item['path']);
$cats[]=爆炸(“/”,$item['path']);
echo$item['name'.-.$item['path'];
回声“
”;
}
印刷(猫);
任何帮助都将不胜感激
谢谢如果我正确理解了这个问题,比如:
array_push($cats[0],'something else');
应该可以工作。我是否可以动态执行此操作?很高兴听到:)。。另一个可能的选项是将键作为数组中的字符串。