I have an array having unique 'table_id' that will find 'parent_id' and goes under parent index.
My Array:
Array
(
[0] => Array
(
[table_id] => 7
[table_name] => Macro
[parent_table] => 1
)
[1] => Array
(
[table_id] => 4
[table_name] => Dise
[parent_table] => 7
)
[2] => Array
(
[table_id] => 5
[table_name] => Cox
[parent_table] => 7
)
[3] => Array
(
[table_id] => 6
[table_name] => Ripo
[parent_table] => 4
)
)
Sample output:
Array
(
[1] => Array
(
[table_id] => 7
[table_name] => Macro
[parent_table] => 1
[7] => Array
(
[table_id] => 4
[table_name] => Dise
[parent_table] => 7
[4] => Array
(
[table_id] => 6
[table_name] => Ripo
[parent_table] => 4
)
)
[7] => Array
(
[table_id] => 5
[table_name] => Cox
[parent_table] => 7
)
)
)
Please give some idea to build this.