I'm using a category system which has parent categories which can have multiple child categories, which can also have child categories and so on… I am trying to use a script which will use the current selected category ID and add all of their children IDs, and their children IDs etc to an array. The recursion works fine, as when I test it with echoing the names/ID's, it shows all of them. Although the array only seems to ever show up to the first set of child categories and no more.
The category database is similar to this:
My current code is as follows:
I seem to be only able to add the first set of child categories to the array and never the whole set, no matter how I position the sections of the code and I have no idea why, for example, it will return something like:
Any help would be appriciated.
View on Stack Overflow
