title: Get country name from latitude and longitude
body: <p>I have a latitude and a longitude, and I need to fetch country.</p>
  
  <p>I am using this:</p>
  
  <pre><code>$geocode_stats = file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?latlng=".$deal_lat.",".$deal_long . "&amp;sensor=false");
  $output_deals = json_decode($geocode_stats);
  $country = $output_deals-&gt;results[2]-&gt;address_components[4]-&gt;long_name;
  </code></pre>
  
  <p>Sometimes it gives a correct country name, but sometimes it gives blank values, and sometimes it returns a city name.</p>
  
  <p>Can anybody help?</p>