重複の可能性:
データベースの結果を配列に変換する
こんにちは、私を助けてください。php 配列または JSON で、db テーブルから階層的な php 構造を取得する方法を次の形式で示します。
[
{
"attributes":{
"id":"111"
},
"data":"Some node title",
"children":[
{
"attributes":{
"id":"555"
},
"data":"A sub node title here"
}
],
"state":"open"
},
{
"attributes":{
"id":"222"
},
"data":"Other main node",
"children":[
{
"attributes":{
"id":"666"
},
"data":"Another sub node"
}
],
"state":"open"
}
]
私の SQL テーブルにはフィールドが含まれています: ID、PARENT、ORDER、TITLE
これで私を助けてもらえますか?私はこれを手に入れようとして夢中になっています。
よろしくお願いします。ダニエル