将数据添加到多维php数组

时间:2014-10-01 18:23:44

标签: php arrays

我有一个输出以下内容的数组:

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] => Array

这是我创建数组的方式:

$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);

非常感谢任何帮助!

由于

1 个答案:

答案 0 :(得分:2)

如果我正确理解了这个问题,那就像:

array_push($cats[0],'something else');

应该有用。