Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从json获取数据的问题_Php_Json - Fatal编程技术网

Php 从json获取数据的问题

Php 从json获取数据的问题,php,json,Php,Json,我已经能够从json访问信息,但我需要更具体的信息。我需要地址。我试过了,但看不出来。我可以得到名字,但当我试图得到地址,我没有得到结果。 下面是json的var_转储 array (size=1) 'NPI' => array (size=30) 0 => array (size=35) 'NPI' => string '1720071798' (length=10) 'EntityT

我已经能够从json访问信息,但我需要更具体的信息。我需要地址。我试过了,但看不出来。我可以得到名字,但当我试图得到地址,我没有得到结果。 下面是json的var_转储

    array (size=1)
  'NPI' => 
    array (size=30)
      0 => 
        array (size=35)
          'NPI' => string '1720071798' (length=10)
          'EntityType' => string 'Individual' (length=10)
          'IsSoleProprietor' => string 'X' (length=1)
          'LastName' => string 'BURGESS-PETERSON' (length=16)
          'FirstName' => string 'HEATHER' (length=7)
          'MiddleName' => string 'MARIE' (length=5)
          'NamePrefix' => string 'DR.' (length=3)
          'Credential' => string 'O.D.' (length=4)
          'FirstLineMailingAddress' => string '15780 RIDGE LN' (length=14)
          'MailingAddressCityName' => string 'SPRING LAKE' (length=11)
          'MailingAddressStateName' => string 'MI' (length=2)
          'MailingAddressPostalCode' => string '49456-1557' (length=10)
          'MailingAddressCountryCode' => string 'US' (length=2)
          'MailingAddressTelephoneNumber' => string '231-719-9200' (length=12)
          'MailingAddressFaxNumber' => string '231-744-6782' (length=12)
          'FirstLinePracticeLocationAddress' => string '1871 HOLTON RD' (length=14)
          'SecondLinePracticeLocationAddress' => string 'SUITE A' (length=7)
          'PracticeLocationAddressCityName' => string 'MUSKEGON' (length=8)
          'PracticeLocationAddressStateName' => string 'MI' (length=2)
          'PracticeLocationAddressPostalCode' => string '49445-1594' (length=10)
          'PracticeLocationAddressCountryCode' => string 'US' (length=2)
          'PracticeLocationAddressTelephoneNumber' => string '231-719-9200' (length=12)
          'PracticeLocationAddressFaxNumber' => string '231-744-6782' (length=12)
          'EnumerationDate' => string '08/25/2005' (length=10)
          'LastUpdateDate' => string '07/08/2007' (length=10)
          'GenderCode' => string 'F' (length=1)
          'Gender' => string 'Female' (length=6)
          'TaxonomyCode1' => string '152W00000X' (length=10)
          'Taxonomy1' => string 'Optometrist' (length=11)
          'LicenseNumber1' => string '4901003806' (length=10)
          'LicenseNumberStateCode1' => string 'MI' (length=2)
          'PrimaryTaxonomySwitch1' => string 'Y' (length=1)
          'OtherIdentifier1' => string 'U68516' (length=6)
          'OtherIdentifierType1' => string 'MEDICARE UPIN' (length=13)
          'OtherIdentifierState1' => string 'MI' (length=2)
      1 => 
        array (size=32)
          'NPI' => string '1588640304' (length=10)
          'EntityType' => string 'Individual' (length=10)
          'IsSoleProprietor' => string 'X' (length=1)
          'LastName' => string 'PETERSON' (length=8)
          'FirstName' => string 'HEATHER' (length=7)
          'MiddleName' => string 'ALYSA' (length=5)
          'Credential' => string 'MS SLP LLL' (length=10)
          'FirstLineMailingAddress' => string '1824 BELMONT RD NW' (length=18)
          'SecondLineMailingAddress' => string '#31' (length=3)
          'MailingAddressCityName' => string 'WASHINGTON' (length=10)
          'MailingAddressStateName' => string 'DC' (length=2)
          'MailingAddressPostalCode' => string '20009' (length=5)
          'MailingAddressCountryCode' => string 'US' (length=2)
          'MailingAddressTelephoneNumber' => string '202-425-6874' (length=12)
          'MailingAddressFaxNumber' => string '703-922-0638' (length=12)
          'FirstLinePracticeLocationAddress' => string '6506 LOISDALE RD' (length=16)
          'SecondLinePracticeLocationAddress' => string 'SUITE #300' (length=10)
          'PracticeLocationAddressCityName' => string 'SPRINGFIELD' (length=11)
          'PracticeLocationAddressStateName' => string 'VA' (length=2)
          'PracticeLocationAddressPostalCode' => string '22150' (length=5)
          'PracticeLocationAddressCountryCode' => string 'US' (length=2)
          'PracticeLocationAddressTelephoneNumber' => string '703-924-4183' (length=12)
          'PracticeLocationAddressFaxNumber' => string '703-922-0638' (length=12)
          'EnumerationDate' => string '12/22/2005' (length=10)
          'LastUpdateDate' => string '07/08/2007' (length=10)
          'GenderCode' => string 'F' (length=1)
          'Gender' => string 'Female' (length=6)
          'TaxonomyCode1' => string '235Z00000X' (length=10)
          'Taxonomy1' => string 'Speech-Language Pathologist' (length=27)
          'LicenseNumber1' => string '12074933' (length=8)
          'LicenseNumberStateCode1' => string 'VA' (length=2)
          'PrimaryTaxonomySwitch1' => string 'Y' (length=1)
      2 => 
        array (size=30)
          'NPI' => string '1861583460' (length=10)
          'EntityType' => string 'Individual' (length=10)
          'IsSoleProprietor' => string 'N' (length=1)
          'LastName' => string 'PETERSON' (length=8)
          'FirstName' => string 'HEATHER' (length=7)
          'MiddleName' => string 'M' (length=1)
          'Credential' => string 'RN' (length=2)
          'FirstLineMailingAddress' => string '2575 N COURTENAY PKWY' (length=21)
          'MailingAddressCityName' => string 'MERRITT ISLAND' (length=14)
          'MailingAddressStateName' => string 'FL' (length=2)
          'MailingAddressPostalCode' => string '32953' (length=5)
          'MailingAddressCountryCode' => string 'US' (length=2)
          'MailingAddressTelephoneNumber' => string '321-639-5787' (length=12)
          'MailingAddressFaxNumber' => string '321-639-5762' (length=12)
          'FirstLinePracticeLocationAddress' => string '2575 N COURTENAY PKWY' (length=21)
          'PracticeLocationAddressCityName' => string 'MERRITT ISLAND' (length=14)
          'PracticeLocationAddressStateName' => string 'FL' (length=2)
          'PracticeLocationAddressPostalCode' => string '32953' (length=5)
          'PracticeLocationAddressCountryCode' => string 'US' (length=2)
          'PracticeLocationAddressTelephoneNumber' => string '321-639-5787' (length=12)
          'PracticeLocationAddressFaxNumber' => string '321-639-5762' (length=12)
          'EnumerationDate' => string '09/27/2006' (length=10)
          'LastUpdateDate' => string '07/08/2007' (length=10)
          'GenderCode' => string 'F' (length=1)
          'Gender' => string 'Female' (length=6)
          'TaxonomyCode1' => string '163WS0200X' (length=10)
          'Taxonomy1' => string 'School' (length=6)
          'LicenseNumber1' => string 'RN9203188' (length=9)
          'LicenseNumberStateCode1' => string 'FL' (length=2)
          'PrimaryTaxonomySwitch1' => string 'Y' (length=1)
现在,我可以将这个名称与我要查找的名称进行比较

$json = json_decode($data,true);
$firstName = strtoupper($firstName);
$lastName = strtoupper($lastName);
var_dump($json);
foreach($json['NPI'] as $key => $val){
//echo $key .'=>'. $val.'<br>';
foreach($val as $item => $info){
    //echo $item .'=>'.$data.'<br>';
    if($item == 'AuthorizedOfficialFirstName' && $info == $firstName){

        echo $firstName.' '.$lastName.'<br>';


     }
    }
  }
}
$json=json\u decode($data,true);
$firstName=strtoupper($firstName);
$lastName=strtoupper($lastName);
var_dump($json);
foreach($json['NPI']作为$key=>$val){
//回显$key.'=>'.$val.
'; foreach($val作为$item=>$info){ //回显$item.'=>'.$data.
'; 如果($item=='AuthorizedOfficialFirstName'&&&$info==$firstName){ 回显$firstName.'.$lastName.'
'; } } } }
当我这样做时,我没有得到任何结果。请帮忙

$json = json_decode($data,true);
$firstName = strtoupper($firstName);
$lastName = strtoupper($lastName);
var_dump($json);
 foreach($json['NPI'] as $key => $val){
//echo $key .'=>'. $val.'<br>';
foreach($val as $item => $info){
    //echo $item .'=>'.$data.'<br>';
    if($item == 'AuthorizedOfficialFirstName' && $info == $firstName){
        if($item == 'FirstLineMailingAddress'){
        echo $firstName.' '.$lastName.'<br>';
        echo $info.'<br>';
        //echo $json['NPI']['FirstLinePracticeLocationAddress'];
     }
    }
   }
}
$json=json\u decode($data,true);
$firstName=strtoupper($firstName);
$lastName=strtoupper($lastName);
var_dump($json);
foreach($json['NPI']作为$key=>$val){
//回显$key.'=>'.$val.
'; foreach($val作为$item=>$info){ //回显$item.'=>'.$data.
'; 如果($item=='AuthorizedOfficialFirstName'&&&$info==$firstName){ 如果($item=='FirstLineMailingAddress'){ 回显$firstName.'.$lastName.'
'; 回显$info.“
”; //echo$json['NPI']['FirstLinePracticeLocationAddress']; } } } }
你的问题就在这里

if($item == 'AuthorizedOfficialFirstName' && $info == $firstName){
    if($item == 'FirstLineMailingAddress'){
$item不能同时为

授权官方域名

以及

一线邮件地址


因此,为什么它没有回声。

你能把确切的json放在你的帖子上吗echo…。或任何您想要检查的内容!这是公开信息