How to convert an array of this type?

[blocks] => Array
(
 [1] => Array
(
 [0] => Array
(
 [id] => 1
 [position] => 1
)

)

 [2] => Array
(
 [0] => Array
(
 [id] => 2
 [position] => 2
)

 [1] => Array
(
 [id] => 3
 [position] => 2
)
)
 )

The question on this array. This array of blocks. The value of [position] => 2 suggests that the unit is in the second line. Accordingly, the array output cycle to cycle. Question - how do I pass the value [position] upward, that is, to convert the array to this
[blocks] => Array
 ( 
 [1] => Array
 ( [position] => 1
 [0] => Array
(
 [id] => 1
 [position] => 1
)

)

 [2] => Array
 ( [position] => 2
 [0] => Array
(
 [id] => 2
 [position] => 2
)

 [1] => Array
(
 [id] => 3
 [position] => 2
)
)
 )
July 9th 19 at 13:27
1 answer
July 9th 19 at 13:29
Solution
1st option through an array in manual to dig in deep to get position;
2nd option - go through the array and create new array with a new structure.
3rd option - initially to create the structure you need
but in terms of accuracy and saving memory - what is the best option to choose? - Liliana_Hickle82 commented on July 9th 19 at 13:32
: 3D. the rest depends on the needs - Pedro_Herzog commented on July 9th 19 at 13:35

Find more questions by tags ArraysPHP