Array
(
[178] => Array
(
)
[179] => Array
(
[180] =>
[181] =>
[182] =>
[183] =>
)
[184] => Array
(
[185] =>
)
[186] => Array
(
)
[189] => Array
(
[190] =>
)
[181] => Array
(
[191] =>
[192] =>
)
[192] => Array
(
[194] =>
)
)
I have a 'linked list' and this PHP array is a list of all the nodes. I have used keys to store unique mysql ID for later lookup. You'll notice that some keys in the 2nd level arrays are the same as first level. I would like to join those arrays so that a lower level gets joined to an upper level in recursive fashion.
eg, 179 -> 181 -> 192 -> 194
There may be many node levels, not just what I have in this example. How do I recursively add all the nodes together into the correct order?
UPDATED I also have an array of all the ends on the node, ie the IDs that have no further nodes.
Array ( [0] => 178 [1] => 180 [2] => 182 [3] => 183 [4] => 185 [5] => 186 [6] => 190 [7] => 191 [8] => 194 )