从PHP中的JSON数组中获取价值 [英] Get value from JSON array in PHP
本文介绍了从PHP中的JSON数组中获取价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从PHP变量中的以下JSON数组中获取值.
I'm trying to get the value from this following JSON array in a PHP variable.
这是数组的var_dump:
This is a var_dump of the array:
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"]的值:
I am able to get the values for ["json"] in PHP like:
$json = $data[0]['json'];
但是如何从"json"内部的数组中获取值,例如"AfterParticipationHeader".还有"Submit_Fields"?
But how do I get the value from from the array inside "json", like "AfterParticipationHeader". And "Submit_Fields" ?
推荐答案
首先,您必须解码json数据
First you have to decode your json data
$json = json_decode($data[0]['json']);
然后您可以访问您的AfterParticipationHeader
$json->Canvas[0]->MainObjects->{"After Participation"}->afterParticipationHeader
这篇关于从PHP中的JSON数组中获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文