in reply to Turn a nested array into a nested set?

It's not immediately clear to me how your expected values are meant to come about (and judging by the fact that no one else has replied yet, I might not be the only one :).  For example, could you elaborate why it should be 8 and 9 in

$VAR4 = [ 5, 8, 9, 'Ryan', 'Oops.' ];

(I suppose the first value is some row ID, reflecting the sequence in which the arrays are encountered while traversing the structure)