title: Fatal error: Cannot use object of type stdClass as array in C:\xampp\htdocs\aiw\index.php
body: <pre><code>&lt;?php
  echo "&lt;h1&gt;What's The Weather Like?&lt;/h1&gt;";
  define('API_KEY','********');
  
  $apikey = API_KEY;
  
  $user_ip = '183.91.3.13'; // Remove comment to use this to test when you put 
     this file in localhost
   //$user_ip = $_SERVER['REMOTE_ADDR']; // Comment out this line if you test 
   in your localhost
    $details = 
   json_decode(file_get_contents("http://ipinfo.io/{$user_ip}/json"));
   $city_name = $details-&gt;city;
   $loc_details = 
  json_decode(file_get_contents("http://dataservice.accuweather.com/locations/v1/ cities/search?q={$city_name}&amp;apikey={$apikey}"));
   $loc_key = $loc_details[0]-&gt;Key;
   $weather_details = 
  
  
  json_decode(file_get_contents("http://dataservice.accuweather.com/forecasts/v1/daily/1day/{$loc_key}?apikey={$apikey}"));
   // print_r($weather_details);
   //  $result = json_decode($data, true);
   echo $weather_details[0]-&gt;EffectiveDate;
  ?&gt;
  </code></pre>
  
  <p>when i try to run the web it shows this problem
  Fatal error: Cannot use object of type stdClass as array in C:\xampp\htdocs\aiw\index.php on line 16
  i hope you dont dislike because i am a new learner</p>