Rewriting this to be more specific.
I have a csv file. Every row has has a field that explodes into an array of representing a category tree. So, the first three rows might become arrays as such:
array('food', 'fruit', 'red', 'apple')
array('food', 'fruit', 'green', 'kiwi')
array('beauty', 'makeup', 'lipstick')
It is supposed to be a tree, though. I need to end up with:
food
fruit
red
apple
green
kiwi
beauty
makeup
lipstick
The main difference from this and the dozens of similar questions I've seen asked and answered is that there is no guaranteed number of levels in each record read, and the distinct likelihood that one record may have no keys in common with another. So array_merge seems to fail as does using +
The only assurance is that for any record, the list of keys is assumed to begin at the top level of the array, so that if there is
rec1 = animal, fish, shark
rec2 = fish, shark, hammerhead
the expected result is
animal
fish
shark
fish
shark
hammerhead