I have a table with id, parent_id and name fields,
a parent can have many child but child have only one parent.
On fetching, the array is look like
Array
(
[0] => Array
(
[id] => 1
[parent_id] => 0
[name]=>firstName
)
[1] => Array
(
[id] => 2
[parent_id] => 1
[name]=>childFirstName
)
[2] => Array
(
[id] => 3
[parent_id] => 0
[name]=>SecondName
)
[3] => Array
(
[id] => 4
[parent_id] => 3
[name]=>childSecondName
)
)
From this table , i want a flat array, which should be look like this..
//The key of array is the id of table row and the value corresponding to id is parent_name >name
Array
(
[1]=>[firstName],// [row_id]=>[name with parent]
[2]=>[firstName>childFirstName],
[3]=>[secondName],
[4]=>[secondName>childSecondName]
)