Nasıl json stdclass diziden belirli bir çizgi ayıklamak?

0 Cevap php

Tamam bu bir Api çağrı

   $json_string = '"offices":
      [{"description": "Google Headquarters",
        "address1": "1600 Amphitheatre Parkway",
        "address2": "",
        "zip_code": "",
        "city": "Mountain View",
        "state_code": "CA",
        "country_code": "USA",
        "latitude": 37.421972,
        "longitude": -122.084143},
       {"description": "Google Ann Arbor",
        "address1": "112 S. Main St.",
        "address2": "2nd Floor",
        "zip_code": "48104",
        "city": "Ann Arbor",
        "state_code": "MI",
        "country_code": "USA",
        "latitude": 42.280988,
        "longitude": -83.748882},
       {"description": "Google Atlanta",
        "address1": "10 10th Street NE",
        "address2": "Suite 600",
        "zip_code": "30309"';//more but trimming here.

$obj=json_decode($json_string);
foreach($obj->offices as $office) {
    echo $office->address1;

     }  

Bu Adres1 üzerine tam sonuç verir. ama ben ilk Adres1 sadece içerik gerekir. Ben bunu nasıl yapabilirim?

0 Cevap