0

I have an array that outputs the following:

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

How would i go about adding an item into the [0] => Array?

This is the way i have created my 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);

Any help would be greatly appreciated!

Thanks

1 Answer 1

2

If I understand the question correctly, something like:

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

should work.

Sign up to request clarification or add additional context in comments.

2 Comments

is there anyway i could do this dynamically?
glad to hear :) .. another possible option could be keys as strings in your array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.