I have the following array:
0 => [
'pid' => 'all'
'id' => 0
]
1 => [
'pid' => 0
'id' => 1
]
2 => [
'pid' => 1
'id' => 2
]
3 => [
'pid' => 1
'id' => 3
]
4 => [
'pid' => 0
'id' => 5
]
5 => [
'pid' => 5
'id' => 7
]
And now I want to create a recursive tree out of this, so that I can generate a HTML structure. The array then should look like this:
0 => [
'id' => 0,
'children' => [
0 => [
'id' => 1
'children' => [
0 => [
'id' => 2
]
1 => [
'id' => 3
]
]
]
1 => [
'id' => 5
'children' => [
0 => [
'id' => 7
]
]
]
]
How can I do that? I couldn't find any solutions that could be helpful here.