请问php怎么才能把如下格式
{
"code": 200,
"message": "操作成功",
"data": [
{
"id": 1,
"goods_id": 1,
"property_name_id": 1,
"property_value_id": 1,
"property_name": {
"title": "份量",
"is_sale": true
},
"property_value": {
"id": 1,
"value": "小份",
"image": ""
}
},
{
"id": 2,
"goods_id": 1,
"property_name_id": 1,
"property_value_id": 2,
"property_name": {
"title": "份量",
"is_sale": true
},
"property_value": {
"id": 2,
"value": "中份",
"image": ""
}
},
{
"id": 3,
"goods_id": 1,
"property_name_id": 2,
"property_value_id": 4,
"property_name": {
"title": "温度",
"is_sale": true
},
"property_value": {
"id": 4,
"value": "常温",
"image": ""
}
},
{
"id": 4,
"goods_id": 1,
"property_name_id": 2,
"property_value_id": 5,
"property_name": {
"title": "温度",
"is_sale": true
},
"property_value": {
"id": 5,
"value": "加冰",
"image": ""
}
}
]
}
遍历成如下格式
{
"code": 200,
"message": "操作成功",
"data": [
{
"property_id": 1,
"property_name": "份量",
"is_sale": true,
"items": [
{
"id": 1,
"value": "小份",
"image": ""
},
{
"id": 2,
"value": "中份",
"image": ""
}
]
},
{
"property_id": 2,
"property_name": "温度",
"is_sale": true,
"items": [
{
"id": 4,
"value": "常温",
"image": ""
},
{
"id": 5,
"value": "加冰",
"image": ""
}
]
}
]
}