gpt4 book ai didi

php - 如何从 db 表、php 数组或 JSON 中获取分层 php 结构

转载 作者:行者123 更新时间:2023-11-29 07:13:51 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Turn database result into array

大家好,能帮帮我吗?如何从 db 表、php 数组或 JSON 中获取分层 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

你能帮我解决这个问题吗?我快要发疯了。

非常感谢。丹尼尔

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com