title: How to obtain location from ipinfo.io in PHP?
body: <p>I am using <a href="http://ipinfo.io" rel="nofollow">ipinfo.io</a> to get my current city (location) using PHP.</p>
  
  <p>However, I am not able to see my city when using this piece of code.</p>
  
  <pre><code>$ipaddress = $_SERVER["REMOTE_ADDR"];
  
  function ip_details($ip) {
      $json = file_get_contents("http://ipinfo.io/{$ip}/geo");
      $details = json_decode($json);
      return $details;
  }
  
  $details = ip_details($ipaddress);
  echo $details-&gt;city;
  </code></pre>
  
  <p>I don't know where the error is.</p>