I realize this is probably a simple question, but after reading the documentation for a while, I haven’t been able to find a solution. I have a multidimensional array in the format shown below. This is my recursive multi Dimensional php array
array:5 [▼
0 => array:3 [▼
"id" => 2
"level" => 0
"email" => "[email protected]"
]
1 => array:2 [▼
0 => array:3 [▼
"id" => 4
"level" => 1
"email" => "[email protected]"
]
1 => array:2 [▼
0 => array:3 [▼
"id" => 5
"level" => 2
"email" => "[email protected]"
]
1 => array:1 [▼
0 => array:3 [▼
"id" => 6
"level" => 3
"email" => "[email protected]"
]
]
]
]
2 => array:3 [▼
"id" => 3
"level" => 0
"email" => "[email protected]"
]
4 => array:3 [▼
"id" => 7
"level" => 0
"email" => "[email protected]"
]
5 => array:2 [▼
0 => array:3 [▼
"id" => 8
"level" => 1
"email" => "[email protected]"
]
1 => array:2 [▼
0 => array:3 [▼
"id" => 9
"level" => 2
"email" => "[email protected]"
]
1 => array:2 [▼
0 => array:3 [▼
"id" => 10
"level" => 3
"email" => "[email protected]"
]
1 => array:2 [▼
0 => array:3 [▼
"id" => 11
"level" => 4
"email" => "[email protected]"
]
1 => array:1 [▼
0 => array:3 [▼
"id" => 12
"level" => 5
"email" => "[email protected]"
]
]
]
]
]
]
]
I want to clean above array and get array like below:
array:3 [▼
0 => array:3 [▼
"id" => 1
"level" => 2
"email" => "[email protected]"
]
1 => array:3 [▼
"id" => 2
"level" => 5
"email" => "[email protected]"
]
2 => array:3 [▼
"id" => 1
"level" => 8
"email" => "[email protected]"
]
]
if possible please include order by id code. Thanks for help.
New contributor
Sherlock Holmes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.