<?php
$json = '{"data":"listCountry","country":[{"zip":11023,"code":"NY"}],"phone":"+1458589994","name":{"firstname":"John","lastname":"Cannor"},"status":"MEMBER"
}';
$a=json_decode($json);
print_r($a->{'country'}[0]->{'zip'}); //output "11023" Success
echo "<br />";
print_r($a->{'country'}[0]->{'code'}); //output "NY" Success
echo "<br />";
echo $a->phone; //output "+1458589994" Success
echo "<br />";
echo $a->status; //output "MEMBER" Success
//this my problem
echo "<br />";
print_r($a->{'name'}[0]->{'firstname'}); //output blank or error
echo "<br />";
print_r($a->{'name'}[0]->{'lastname'}); //output blank or error
?>
how do I retrieve the json string "name": {"firstname": "John", "lastname": "Cannor"} to php in my json ? i am put php code
print_r($a->{'name'}[0]->{'firstname'});
and
print_r($a->{'name'}[0]->{'lastname'});
is error or blank page