"data":{
"2":{
"sub_category_id":"1",
"product":[
{
"sub_category_id":"1",
"product_id":"1",
"product_name":"American"
},
{
"sub_category_id":"1",
"product_id":"34",
"product_name":"Ausi Product"
}
]
},
"3":{
"sub_category_id":"2",
"product":{
"2":{
"sub_category_id":"2",
"product_id":"2",
"product_name":"Canadian"
}
}
}
}
我除结果:
"data":[
"2":{
"sub_category_id":"1",
"product":[
{
"sub_category_id":"1",
"product_id":"1",
"product_name":"American"
},
{
"sub_category_id":"1",
"product_id":"34",
"product_name":"Ausi Product"
}
]
},
"3":{
"sub_category_id":"2",
"product":[
"2":{
"sub_category_id":"2",
"product_id":"2",
"product_name":"Canadian"
}
]
]
即。我想要数据和产品之后。
您可以指示PHP json_decode()
函数将对象解析为关联数组。
$parsedJSON = json_decode($jsonString, /* $assoc = */ true)