我有以下json数据:
{
"name" : "Template1",
"data" : {
"columns" : [
{
"name" : "Brand Size",
"record" : [
{
"fname" : "column_search",
"fields" : [
{
"name" : "column_search_form_search",
"value" : "332"
},
],
"rules" : [
{
"rules_info_cond" : "if",
}
]
},
{
"name" : "vendorArticleName",
"record" : [
{
"fname" : "column_search",
"rules" : [
{
"rules_info_cond" : "if",
}
]
},
{
"name" : "Remarks",
"record" : [
{
"fname" : "column_information_show",
"rules" : [
[
]
]
},
}
我想获取具有fname ='column_information_show'的data-> columns-> name 我可以使用MongoDB查找,但不能使用PHP查找。请帮帮我!
答案 0 :(得分:0)
$array = json_decode($jsonData, true);
foreach($array['data']['columns'] as $value) {
if($value['record']['fname'] == 'column_information_show'){
return $value;
}
}
这将循环遍历您的json数据,并返回fname等于column_information_show的第一列。如果要返回多个列,可以将它们添加到数组中,然后在以后返回。