我要做的是查找对象名称'imm-sale-value_Huvudbild-fr-kostnadsfrslag',然后将其删除。
$JsonOrder_field =
{
"imm-sale-value_step_completed_ladda-upp-bilder-till-affrsfrslaget-hr": {
"label": "",
"value": "1",
"summary_placement": null,
"image_description": null
},
"imm-sale-value_Huvudbild-fr-kostnadsfrslag": {
"label": "Huvudbild f\u00f6r kostnadsf\u00f6rslag",
"value": "bg.png",
"summary_placement": "hero",
"image_description": ""
},
"imm-sale-value_Bildruta-1-Kostnadsfrslag": {
"label": "Bildruta 1 Kostnadsf\u00f6rslag",
"value": "2_bg.png",
"summary_placement": "b1",
"image_description": ""
},
"imm-sale-value_Bildruta-3-Kostnadsfrslag": {
"label": "Bildruta 3 Kostnadsf\u00f6rslag",
"value": "bg.jpg",
"summary_placement": "false",
"image_description": ""
}
}
$JsonOrder_field_decode = json_decode($JsonOrder_field, JSON_FORCE_OBJECT);
我试图做一个foreach循环,但是并没有给我对象名称,而只是给出了({lable, value, summary_placement, image_descriotion
)。
对如何搜索所需对象有任何帮助或建议吗?
答案 0 :(得分:0)
您可以使用PHP UNSET()从数组中删除元素或数组 这是代码:
<?php
$JsonOrder_field ='
{
"imm-sale-value_step_completed_ladda-upp-bilder-till-affrsfrslaget-hr": {
"label": "",
"value": "1",
"summary_placement": null,
"image_description": null
},
"imm-sale-value_Huvudbild-fr-kostnadsfrslag": {
"label": "Huvudbild f\u00f6r kostnadsf\u00f6rslag",
"value": "bg.png",
"summary_placement": "hero",
"image_description": ""
},
"imm-sale-value_Bildruta-1-Kostnadsfrslag": {
"label": "Bildruta 1 Kostnadsf\u00f6rslag",
"value": "2_bg.png",
"summary_placement": "b1",
"image_description": ""
},
"imm-sale-value_Bildruta-3-Kostnadsfrslag": {
"label": "Bildruta 3 Kostnadsf\u00f6rslag",
"value": "bg.jpg",
"summary_placement": "false",
"image_description": ""
}
}
';
$JsonOrder_field_decode = json_decode($JsonOrder_field, JSON_FORCE_OBJECT);
unset($JsonOrder_field_decode['imm-sale-value_Huvudbild-fr-kostnadsfrslag']);
print_r($JsonOrder_field_decode);
?>