hello I using laravel and magento DB to get data, I want to make tree like structure of following data. Initially when I got data is like this.
Array
(
[parent] => Array
(
[0] => Array
(
[entity_id] => 5740
[name] => Sports
[parent_id] => 5739
)
[1] => Array
(
[entity_id] => 6057
[name] => Football
[parent_id] => 5740
)
[2] => Array
(
[entity_id] => 6058
[name] => American
[parent_id] => 6057
)
)
)
and I want the above data in following format to use in my application.
Array
(
[parent] => Array
(
[0] => Array
(
[entity_id] => 5740
[name] => Sports
[parent_id] => 5739
[child] => Array
(
[entity_id] => 6057
[name] => Football
[parent_id] => 5740
[child]=> Array
(
[entity_id] => 6058
[name] => American
[parent_id] => 6057
)
)
)
)
)
can anyone please help me in this.