Eric Evans Eric Evans - 3 months ago 10
PHP Question

Reorder array to remove upper level 0 index

I'm wanting to know how I can reindex my array that has a upper level index [0]

My array looks like this

$test = array(
[0] => array(
id = 1
)
)


What I want is

$test = array(
id = 1
)


I know that I can do a foreach to get what I want, but wondering is there a function that does the samething.

Answer

This should do it with the example you gave:

$test = $test[0];

If your problem is more complex, tell us more.

Comments