Title isn't great, but I think I can explain better what I want to achieve like so:
Given a flat file:
MAIN 0
Sub Heading 0
Sub Heading 1
MAIN 1
Sub Heading 0
Sub Sub Heading 0
Sub Sub Heading 1
Sub Heading 1
Sub Heading 2
Sub Sub Heading 0
Sub Sub Sub Heading 0
MAIN 2
Sub Heading 0
How can I create a nested 'array of arrays' structure from this? A child is defined by being prepended by a TAB character from it's parent.
I am trying to do this in php, currently, and don't have much work to show. I'm stuck trying to work out the logic.
I believe the best solution will probably be some kind of recursion, and perhaps a tab_count variable and a tab_count_ceiling variable?
I started doing this in php, but honestly, I have no language preference for this. Which code can solve such a problem?