If you have a text file like this:
item1
item1 > item3
item1 > item3 > item4
item1 > item5
item1 > item5 > item6 > item7
item2 > item8
item2 > item8 > item9
And I want a array that looks like this:
array(
[item1]
array(
[item3]
array(
[item4]
)
[item5]
array(
[item6]
array(
[item7]
)
)
)
[item2]
array(
[item8]
array(
[item9]
)
)
)
How should I make this in PHP? I have no idea where to start. Thanks.
Here's a very simple way to approach your problem. The result is not exactly the same (the last element is also an array) but this is more flexible I think:
demo: http://codepad.viper-7.com/IwZFQ3