Can I represent a tree data structure in PHP?
$data = array( 'tree' => array( 'branch1' => array( 'some','data' ) ,'branch2' => array( 'more','data' ) ) ,'etc.' => array( 'and','so','on' ) );
If so, would I store the questions in a data base or some sort of other XML data structure?
That’s a bit more involved. How are you going to use these questions? Will you ever need to retrieve individual questions? Are questions expected to change content and/or positions? be added or removed often (or temporarily)? Are you going to have lots of questions or branches? Is there metadata (e.g., answers or conditions about when to use) associated with individual questions?
If you answer “no” to all of those, then xml could work just fine. I would actually recommend JSON instead, however – it is much easier and quicker to author, manipulate, and store.
Otherwise, I would suggest a database. You could try an object-oriented database (e.g., Mongo) if you want to preserve the tree structure. If you wanted to use a relational database (e.g., MySQL), you have to do a bit more work to represent that tree structure.