Hello,
I've successfully created a recursive array function that creates an unordered list menu. My problem is that I would like to remove certain values from this array but haven't been able to figure it out in almost two days.
The values I'd like to use are topics certain users don't have permissions/access to.
However I would like to keep the URL path proper if there is a sub-topic with allowed permissions below another topic that has no access.
I.e.:
Main topic
-Sub-topic No Access
- Sub-sub topic
If a sub-topic or topic doesn't have any children and no access/permissions I want it removed entirely.
The problem I realized is that I would need to start removing backwards from the depest level. Because I may as well have:
Main topic
-Sub-topic No Access
-Sub-sub-topic No Access
-Sub-sub-sub-topic No Access
-Sub-sub-sub-sub-topic
How can I recursively remove values from a multidimensional array starting at each tree's deepest level?
My ideas would be to either reverse to whole set (which I haven't figure out to do) or to somehow walk the array to each deepest level then delete and reverse back to see if I can delete again...and re-doing until I'm at level 0 and then progress to the next set of sub-topics (if any).
Has anybody ever stumbled upon a similar task or would be able to offer me some tips?