i have a json response as below:
stdClass Object ( [lat] => 28.4047 [lon] => 77.34756 ) ) [dataSources] => stdClass Object ( [geometry] => stdClass Object ( [id] => a9f00ae3-3389-47cf-9173-4dfb47bf4d18 ) ) ) [1] => stdClass Object ( [type] => Geography [id] => IN/GEO/p0/285058 [score] => 6.7174906731 [entityType] => CountrySecondarySubdivision [matchConfidence] => stdClass Object ( [score] => 1 ) [address] => stdClass Object ( [countrySecondarySubdivision] => New Delhi [countrySubdivision] => Delhi [countryCode] => IN [country] => India [countryCodeISO3] => IND [freeformAddress] => New Delhi, Delhi ) [position] => stdClass Object ( [lat] => 28.63243 [lon] => 77.21879 ) [viewport] => stdClass Object ( [topLeftPoint] => stdClass Object ( [lat] => 28.88382 [lon] => 76.83895 ) [btmRightPoint] => stdClass Object ( [lat] => 28.4047 [lon] => 77.34756 ) ) [boundingBox] => stdClass Object ( [topLeftPoint] => stdClass Object ( [lat] => 28.88382 [lon] => 76.83895 ) [btmRightPoint] => stdClass Object ( [lat] => 28.4047 [lon] => 77.34756 ) ) [dataSources] => stdClass Object ( [geometry] => stdClass Object ( [id] => ab9398e4-fade-44a7-8391-9cbe1bfb6c05 ) ) ) [2] => stdClass Object ( [type] => Geography [id] => US/GEO/p0/266 [score] => 6.6825494766 [entityType] => Municipality [matchConfidence] => stdClass Object ( [score] => 0.95140634887254 ) [address] => stdClass Object ( [municipality] => Delhi [countrySecondarySubdivision] => Delaware [countrySubdivision] => NY [countrySubdivisionName] => New York [countryCode] => US [country] => United States [countryCodeISO3] => USA [freeformAddress] => Delhi, NY ) [position] => stdClass Object ( [lat] => 42.27959 [lon] => -74.91376 ) [viewport] => stdClass Object ( [topLeftPoint] => stdClass Object ( [lat] => 42.35012 [lon] => -75.03966 ) [btmRightPoint] => stdClass Object ( [lat] => 42.2001 [lon] => -74.79528 ) ) [boundingBox] => stdClass Object ( [topLeftPoint] => stdClass Object ( [lat] => 42.35012 [lon] => -75.03966 ) [btmRightPoint] => stdClass Object ( [lat] => 42.2001 [lon] => -74.79528 ) ) [dataSources] => stdClass Object ( [geometry] => stdClass Object ( [id] => 0000554e-3100-3c00-0000-00005968d7ab ) ) ) [3] => stdClass Object ( [type] => Street [id] => CA/STR/p0/284753 [score] => 6.6427330971 [matchConfidence] => stdClass Object ( [score] => 1 ) [address] => stdClass Object ( [streetName] => New Delhi Drive [municipality] => Markham [countrySubdivision] => ON [countrySubdivisionName] => Ontario [postalCode] => L3S [extendedPostalCode] => L3S 0B5, L3S 0B6, L3S 0E1 [countryCode] => CA [country] => Canada [countryCodeISO3] => CAN [freeformAddress] => New Delhi Drive, Markham ON L3S [localName] => Markham ) [position] => stdClass Object ( [lat] => 43.84986 [lon] => -79.25194 ) [viewport] => stdClass Object ( [topLeftPoint] => stdClass Object ( [lat] => 43.85161 [lon] => -79.25371 ) [btmRightPoint] => stdClass Object ( [lat] => 43.84774 [lon] => -79.25104 ) ) ) [4] => stdClass Object ( [type] => Street [id] => MA/STR/p0/43353 [score] => 6.5971131325 [matchConfidence] => stdClass Object ( [score] => 1 ) [address] => stdClass Object ( [streetName] => Rue New Delhi [municipalitySubdivision] => Hay Narjiss C [municipality] => Fès [countrySecondarySubdivision] => Fès [countrySubdivision] => Fès-Meknès [postalCode] => 30000 [countryCode] => MA [country] => Royaume du Maroc [countryCodeISO3] => MAR [freeformAddress] => Rue New Delhi, Fès [localName] => Fès ) [position] => stdClass Object ( [lat] => 34.01301 [lon] => -4.96909 ) [viewport] => stdClass Object ( [topLeftPoint] => stdClass Object ( [lat] => 34.01366 [lon] => -4.96909 ) [btmRightPoint] => stdClass Object ( [lat] => 34.01278 [lon] => -4.96908 ) ) ) [5] => stdClass Object ( [type] => Street [id] => US/STR/p1/3247292 [score] => 6.5971131325 [matchConfidence] => stdClass Object ( [score] => 1 ) [address] => stdClass Object ( [streetName] => New Delhi Street [municipality] => Mission Viejo [countrySecondarySubdivision] => Orange [countrySubdivision] => CA [countrySubdivisionName] => California [postalCode] => 92691 [extendedPostalCode] => 92691-3036 [countryCode] => US [country] => United States [countryCodeISO3] => USA [freeformAddress] => New Delhi Street, Mission Viejo, CA 92691 [localName] => Mission Viejo ) [position] => stdClass Object ( [lat] => 33.61677 [lon] => -117.68538 ) [viewport] => stdClass Object ( [topLeftPoint] => stdClass Object ( [lat] => 33.61709 [lon] => -117.68614 ) [btmRightPoint] => stdClass Object ( [lat] => 33.61629 [lon] => -117.68485 ) ) ) [6] => stdClass Object ( [type] => Street [id] => US/STR/p3/5079412 [score] => 6.5971131325 [matchConfidence] => stdClass Object ( [score] => 1 ) [address] => stdClass Object ( [streetName] => New Delhi Drive [municipality] => Winston-Salem [countrySecondarySubdivision] => Forsyth [countrySubdivision] => NC [countrySubdivisionName] => North Carolina [postalCode] => 27101 [extendedPostalCode] => 27101-6211, 27101-6212 [countryCode] => US [country] => United States [countryCodeISO3] => USA [freeformAddress] => New Delhi Drive, Winston-Salem, NC 27101 [localName] => Winston-Salem ) [position] => stdClass Object ( [lat] => 36.10693 [lon] => -80.16839 ) [viewport] => stdClass Object ( [topLeftPoint] => stdClass Object ( [lat] => 36.10755 [lon] => -80.16918 ) [btmRightPoint] => stdClass Object ( [lat] => 36.10669 [lon] => -80.16689 ) ) ) [7] => stdClass Object ( [type] => Street [id] => TN/STR/p0/70380 [score] => 6.5769629478 [matchConfidence] => stdClass Object ( [score] => 1 ) [address] => stdClass Object ( [streetName] => Rue New Delhi [municipality] => Nabeul [countrySubdivision] => Nabeul [postalCode] => 8062 [countryCode] => TN [country] => Tunisie [countryCodeISO3] => TUN [freeformAddress] => Rue New Delhi, Nabeul, Nabeul, 8062 [localName] => Nabeul ) [position] => stdClass Object ( [lat] => 36.45945 [lon] => 10.72407 ) [viewport] => stdClass Object ( [topLeftPoint] => stdClass Object ( [lat] => 36.45994 [lon] => 10.72354 ) [btmRightPoint] => stdClass Object ( [lat] => 36.45942 [lon] => 10.72501 ) ) ) [8] => stdClass Object ( [type] => Street [id] => MA/STR/p0/39795 [score] => 6.5334854126 [matchConfidence] => stdClass Object ( [score] => 1 ) [address] => stdClass Object ( [streetName] => Rue de New Delhi [municipalitySubdivision] => Quartier Océan [municipality] => Rabat [countrySecondarySubdivision] => Rabat [countrySubdivision] => Rabat-Salé-Kénitra [postalCode] => 10040 [countryCode] => MA [country] => Royaume du Maroc [countryCodeISO3] => MAR [freeformAddress] => Rue de New Delhi, Rabat [localName] => Rabat ) [position] => stdClass Object ( [lat] => 34.02593 [lon] => -6.84509 ) [viewport] => stdClass Object ( [topLeftPoint] => stdClass Object ( [lat] => 34.02666 [lon] => -6.84546 ) [btmRightPoint] => stdClass Object ( [lat] => 34.02585 [lon] => -6.84505 ) ) ) [9] => stdClass Object ( [type] => Street [id] => TN/STR/p0/5475 [score] => 6.5137228966 [matchConfidence] => stdClass Object ( [score] => 1 ) [address] => stdClass Object ( [streetName] => Rue de New Delhi [municipalitySubdivision] => Sousse Riadh [municipality] => Sousse [countrySubdivision] => Sousse [postalCode] => 4031 [countryCode] => TN [country] => Tunisie [countryCodeISO3] => TUN [freeformAddress] => Rue de New Delhi, Sousse, Sousse, 4031 [localName] => Sousse ) [position] => stdClass Object ( [lat] => 35.79514 [lon] => 10.59245 ) [viewport] => stdClass Object ( [topLeftPoint] => stdClass Object ( [lat] => 35.79534 [lon] => 10.59192 ) [btmRightPoint] => stdClass Object ( [lat] => 35.79492 [lon] => 10.59293 ) ) ) ) )
i want to get the the "lat" and "lon" elemeent from the response , so i tried:
$testGeocode=file_get_contents('https://api.tomtom.com/search/2/geocode/{'.urlencode($addressFromCity).'}.{ext}?key=__my_api_key__here__');
// print_r($testGeocode);
$geocode=json_decode($testGeocode);
print_r($geocode['lat']);
but it gives me nothing ? can someone please tell me how to get lat and lon element from the json response