I have a taken a tree input as PHP string
e.g ((APPLE MANGO)(BALL BAT))
I have an application in which the users select a REFERENCE object. In this example if the user selects BALL as reference object, then my string must become
((BALL MANGO)(APPLE BAT))
i.e the REFERENCE object and the first object must be swapped...
Please suggest some solutions. How can i manipulate this string using PHP.