Home  >  Article  >  Backend Development  >  javascript - How to use php to generate data in json format that can extract hierarchical structure?

javascript - How to use php to generate data in json format that can extract hierarchical structure?

WBOY
WBOYOriginal
2016-08-23 09:17:46916browse

javascript - How to use php to generate data in json format that can extract hierarchical structure?

The picture shows the structure of a table in the database, pid represents the id of the parent node of the current node
How to use php to generate data in json format that can extract the hierarchical structure?

Reply content:

javascript - How to use php to generate data in json format that can extract hierarchical structure?

The picture shows the structure of a table in the database, pid represents the id of the parent node of the current node
How to use php to generate data in json format that can extract the hierarchical structure?

What form of data do you want? This is handled directly with foreach. Just use json_decode to convert it again

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn