|
First OP I would drop the category/subcategory and just go with a single array and associate each element with a parent via a parent ID.
Storing your data in a database for instance you schema might look like:
categories:
pkid, parent, name
The data would resemble something like:
1, 0, Food
2, 1, Meat
3, 1, Cheese
4, 1, Potatoes
The second field (parent ID) is what you use to relate categories with each other, so a ZERO value would indicate that the element is a root item and has no parent.
Food
Meat
Cheese
Potatoes
Your depth is now arbitrary, you just need to update relation ID's
|