Would like to turn text with nested parenthesis to a nested array. Here is an example output from an NLP parser:

(TOP (S (NP (PRP I)) (VP (VBP love) (NP (NP (DT a) (JJ big) (NN bed)) (PP (IN of) (NP (NNS roses))))) (. .)))

(orig: I love a big bed of roses.)

Would like to turn this into a nested array so it will look sg like this

TOP
 S
  NP
   PRP I
  VP 
   VBP Love

etc.

Found this php curly braces into array but that is not a nested array

Edit
Report