I have the following structure
[
{
"category_id" : 1,
"parent_category" : null
} ,
{
"category_id" : 2,
"parent_category" : 1
},
{
"category_id" : 3,
"parent_category" : 1
},
{
"category_id" : 4,
"parent_category" : 2
},
,
{
"category_id" : 5,
"parent_category" : null
},
,
{
"category_id" : 6,
"parent_category" : 5
}
]
so I have parent children relation , I want to sort it with the following structure
[
{
"parent_category":[ "array of all children that follow this main parent category" ]
},
{},
{}
]
I,ve seen many solution but all of it about tree structure output
Thanks