从PHP中的JSON数组中获取价值
这是数组的var_dump:
array(3) { ["id"]=>
string(2) "14"
["css"]=>
string(400) ""
["json"]=>
string(4086) "
{
"Canvas": [
{
"MainObjects": {
"After Participation": {
"afterParticipationHeader": "Thank you!"
},
"Invite Friends": {
"InviteHeadline": "",
"InviteMsg": "",
"InviteImg": ""
}
},
"QuizModule": {
"Questions": [],
"Submit_Fields": [
{
"label": "Name",
"name": "txtName",
"value": true
}
]
}
}
]
}"
}
我可以像这样在PHP中获取[“ json”]的值:
$json = $data[0]['json'];
但是,如何从“ json”内部的数组中获取值,例如“ AfterParticipationHeader”。和“ Submit_Fields”?
回答:
首先,您必须解码json数据
$json = json_decode($data[0]['json']);
然后您可以访问 AfterParticipationHeader
$json->Canvas[0]->MainObjects->{"After Participation"}->afterParticipationHeader
以上是 从PHP中的JSON数组中获取价值 的全部内容, 来源链接: utcz.com/qa/409953.html