I am trying to take a flat array and recreate it so that it's multidimensional. I've been looking into array_combine and array_merge, but I'm not sure that either of those will give me what I'm hoping for...
The array, in it's current form (and this is just a simplified example):
Array
(
[0] => stdClass Object
(
[tid] => 31
[name] => Safeway
[parents] => Array
(
[0] => 0
)
)
[1] => stdClass Object
(
[tid] => 32
[name] => Dairy
[parents] => Array
(
[0] => 31
)
)
[2] => stdClass Object
(
[tid] => 33
[name] => Milk
[parents] => Array
(
[0] => 32
)
)
)
I'm trying to create a multidimensional array where each object is a subarray of it's parent. So, in the example above, I'm trying to output:
Array
(
[0] => stdClass Object
(
[tid] => 31
[name] => Safeway
[children] => Array
(
[tid] => 32
[name] => Dairy
[children] => Array
(
[tid] => 33
[name] => Milk
)
)
)
)