enter image description here I encountered a problem (I searched the network, did not find anything sensible) how to implement a hierarchical question question tree. (Example in the picture)

Question - What the user sends.
Answer - What the user receives in response

Questions come in JSON format from VKontakte.

The network describes the tree sections for sites and output from MySQL, but this is not what you need. I would be grateful for the help ...

  • one
    What is a hierarchical tree? Though I do not see any hierarchy. Do you do something like a bot to which messages are sent, and does he respond to them? - singlesly
  • @singlesly Essentially, yes, but the point is that he understands the commands in a strict sequence. That is, if he is written in the sequence A-> B-> C-> G, he answers and works, but if he is written in the sequence A-> C-> D-> B he will not do anything or send a previously prepared answer .. - Timofey Kucherbaev
  • @singlesly, updated the image for more understanding ... - Timofey Kucherbayev
  • Well, that you do not understand? In php, you can make nested arrays. You can create any complex structure. If you wrap it all up in a class, it will be generally beautiful - ArchDemon 3:49 pm
  • I do not pretend to be true. I just figured out on the basis of experience. And from what I would repel. You will need for each user, for each message to store information about the state of the team. That is, user 1 has now written command A. It means that only commands B and C are available. And user 2 wrote command D means the bot can only answer to U and F. If the command is not available, then the bot responds to the default message. In general, a difficult thing and not convenient for the user, they constantly have to go out of the range of commands to a higher level. But it is quite realizable. - singlesly

0