Google maps api how to get country an cities from dynamically changed addresses

By this code want to get from address some info: lat, lng, country and city. But have a problem with last two items, because number of line dynamically changing at result list.

$curl = curl_init();

        curl_setopt($curl, CURLOPT_URL, 'https://maps.googleapis.com/maps/api/geocode/json?address=' . rawurlencode('ADDRESS') . '&key=YOUR_KEY');

        curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);

        $json = json_decode(curl_exec($curl));

        curl_close ($curl);


        dd($json->results[0]->geometry->location->lat, $json->results[0]->geometry->location->lng, country = $json->{'results'}[0]->{'address_components'}[4]->{'long_name'}, $json->results[0]);

For example, address 'Mohrenstraße, Berlin, Germany' by code $json->{'results'}[0]->{'address_components'}[4]->{'long_name'} print "Germany" (country), but address 'Hetmańska 10, Poznań, Poland' by code $json->{'results'}[0]->{'address_components'}[4]->{'long_name'} print "Poznań" (city). With the same method - different information. What do I need to use to always pull the right information?