Going for days now, ready to quit. I make a call to eBay's trading API to return a list of categories. The array below shows how these categories are returned from the API. I am trying like hell to arrange it into a taxonomy like the first gray box below.
Do note that the number at the beginning of each line is the id of the final category for that particular line.
3270: Vehicle Electronics & GPS
175716: Vehicle Electronics & GPS > Car Audio
18805: Vehicle Electronics & GPS > Car Audio > Car Subwoofers
18795: Vehicle Electronics & GPS > Car Audio > Car Amplifiers
39754: Vehicle Electronics & GPS > Car Audio > Car Audio In-Dash Units
I have greatly shortened this array to one example. Many categories will be pumped through to build the taxonomy.
The CategoryLevel can start at any number and it can end at any number. In this example, it starts at 2 and the highest level is 4.
Array
(
[3270] => Array
(
[CategoryID] => 3270
[CategoryLevel] => 2
[CategoryName] => Vehicle Electronics & GPS
[CategoryParentID] => 293
)
[175716] => Array
(
[CategoryID] => 175716
[CategoryLevel] => 3
[CategoryName] => Car Audio
[CategoryParentID] => 3270
)
[79839] => Array
(
[CategoryID] => 79839
[CategoryLevel] => 4
[CategoryName] => Signal Processors
[CategoryParentID] => 175716
[LeafCategory] => true
)
[18805] => Array
(
[CategoryID] => 18805
[CategoryLevel] => 4
[CategoryName] => Car Subwoofers
[CategoryParentID] => 175716
[LeafCategory] => true
)
[18795] => Array
(
[CategoryID] => 18795
[CategoryLevel] => 4
[CategoryName] => Car Amplifiers
[CategoryParentID] => 175716
[LeafCategory] => true
)
[39754] => Array
(
[CategoryID] => 39754
[CategoryLevel] => 4
[CategoryName] => Car Audio In-Dash Units
[CategoryParentID] => 175716
[LeafCategory] => true
)
)
Thank you in advance for your help!