简体   繁体   English

为什么我收到通知:未定义索引:CIRReportData JSON PHP

[英]Why I am getting Notice: Undefined index: CIRReportData JSON PHP

  <?php
  $response = '{
"CCRResponse": {
    "Status": "1",
    "CIRReportDataLst": [
        {
            "CIRReportData": {
                "IDAndContactInfo": {
                    "PersonalInfo": {
                        "Name": {
                            "FullName": "URMILA GUPTA ",
                            "FirstName": "URMILA ",
                            "LastName": "GUPTA "
                        },
                        " AliasName": {},
                        "DateOfBirth": "1951-11-05"
                    }
                }
            }
        }
    ]
}
    }';
   $r1 = json_encode(json_decode($response), JSON_PRETTY_PRINT);
  $obj = json_decode($response, true);
     foreach ($obj["CCRResponse"]["CIRReportDataLst"] as $key) {
     echo $fullname = $key["CIRReportData"]["IDAndContactInfo"]["PersonalInfo"]["Name"] 
   ["FullName"];
        }?>

Can any help me why I am getting任何可以帮助我为什么我得到

Notice: Undefined index: CIRReportData error?注意:未定义索引:CIRReportData 错误?

I am able to get a response from my code but still getting errors.我能够从我的代码中得到响应,但仍然出现错误。 You can find the full code here.你可以在这里找到完整的代码。 Stack overflow doesn't all me to post full https://app.box.com/s/sxt0eygha3ltx9bc59u0kn0kf0qqfzcm堆栈溢出并不都是我发布完整的https://app.box.com/s/sxt0eygha3ltx9bc59u0kn0kf0qqfzcm

foreach ($obj["CCRResponse"]["CIRReportDataLst"] as $key) {
  if (isset($key["CIRReportData"]["IDAndContactInfo"]["PersonalInfo"]["Name"]["FullName"])) {
    echo $key["CIRReportData"]["IDAndContactInfo"]["PersonalInfo"]["Name"]["FullName"];
  }
}

It worked for me.它对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM