A
A
Alexander2015-10-10 00:55:37
PHP
Alexander, 2015-10-10 00:55:37

How to remove parent array keys?

There is a code:

$mas = array();
        foreach ($selected as $select) {
            $mas[] = [$select['category_id'] => ['Selected' => true]];
        };
        print_r($mas);

print_r :
Array
(
    [0] => Array
        (
            [1] => Array
                (
                    [Selected] => 1
                )

        )

    [1] => Array
        (
            [2] => Array
                (
                    [Selected] => 1
                )
        )
)

How to remove 0 and 1 to make it look like this:
[1] => Array
        (
            [Selected] => 1
        )
[2] => Array
        (
            [Selected] => 1
        )

Not by hand.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2015-10-10
@kentuck1213

$mas[$select['category_id']] = ['Selected' => true];
So?
Or it is impossible to form an array correctly at once according to the condition of the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question