title: use openweathermap with PHP
body: <p>I am trying to give out data from openweathermap  with PHP.I already have a code and it works perfectly. But if i want to add a weather description or Icon an then open the site it won't work. The error is : <strong>"Notice: Trying to get property of non-object in C:\xampp\htdocs\wetter\wetter.php on line 40"</strong>.Here is my code :</p>
  
  <pre><code>if(isset($city)) {
  $url = 'http://openweathermap.org/data/2.1/find/name?q='.urlencode($city).'&amp;cnt=1&amp;lang=de';
  
  $curl = curl_init();
  $headers = array();
  curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($curl, CURLOPT_HEADER, 0);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_URL, $url);
  curl_setopt($curl, CURLOPT_TIMEOUT, 30);
  $json = curl_exec($curl);
  curl_close($curl);
  
  $data = json_decode($json);
  
  if(!empty($data-&gt;list[0]-&gt;name)) {
  ?&gt;
  &lt;div&gt;
     Stadt: &lt;strong&gt;&lt;?php echo $data-&gt;list[0]-&gt;name ?&gt;&lt;/strong&gt;&lt;br /&gt;
     Aktuell:&lt;strong&gt;&lt;?php echo number_format($data-&gt;list[0]-&gt;main-&gt;temp - 273.15, 1, ',', '') ?&gt; &amp;deg; C &lt;/strong&gt;&lt;br /&gt;
     Temperatur (heute):  &lt;br /&gt;
     min. &lt;?php echo number_format($data-&gt;list[0]-&gt;main-&gt;temp_min - 273.15, 1, ',', '') ?&gt; &amp;deg; C&lt;br /&gt;
     max. &lt;?php echo number_format($data-&gt;list[0]-&gt;main-&gt;temp_max - 273.15, 1, ',', '') ?&gt; &amp;deg; C&lt;br /&gt;
     Luftfeuchtigkeit: &lt;?php echo number_format($data-&gt;list[0]-&gt;main-&gt;humidity)?&gt; %&lt;br /&gt;
     Windgeschwindigkeit: &lt;?php echo $data-&gt;list[0]-&gt;wind-&gt;speed ?&gt;m/s&lt;br /&gt;
     Windrichtung: &lt;?php echo $data-&gt;list[0]-&gt;wind-&gt;deg ?&gt;&amp;deg;&lt;br /&gt;
     Wolken: &lt;?php echo $data-&gt;list[0]-&gt;clouds-&gt;all ?&gt;%&lt;br /&gt;
     &lt;b&gt;Wetter: &lt;?php echo $data-&gt;list[0]-&gt;weather-&gt;description ?&gt;&lt;b&gt;&lt;br /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>output of var_dump:</p>
  
  <pre><code>object(stdClass)#1 (7) { ["message"]=&gt; string(0) "" ["cod"]=&gt; string(3) "200" ["type"]=&gt; string(4) "base" ["calctime"]=&gt; string(0) "" ["units"]=&gt; string(8) "internal" ["count"]=&gt; int(1) ["list"]=&gt; array(1) { [0]=&gt; object(stdClass)#2 (11) { ["id"]=&gt; int(0) ["coord"]=&gt; object(stdClass)#3 (2) { ["lat"]=&gt; float(47.366669) ["lon"]=&gt; float(8.55) } ["name"]=&gt; string(6) "Zurich" ["main"]=&gt; object(stdClass)#4 (5) { ["temp"]=&gt; float(282.71) ["pressure"]=&gt; int(1021) ["humidity"]=&gt; int(76) ["temp_min"]=&gt; float(280.93) ["temp_max"]=&gt; float(284.82) } ["dt"]=&gt; int(1462265876) ["date"]=&gt; string(19) "2016-05-03 08:57:56" ["wind"]=&gt; object(stdClass)#5 (2) { ["speed"]=&gt; int(1) ["deg"]=&gt; int(0) } ["clouds"]=&gt; object(stdClass)#6 (1) { ["all"]=&gt; int(40) } ["weather"]=&gt; array(1) { [0]=&gt; object(stdClass)#7 (4) { ["id"]=&gt; int(802) ["main"]=&gt; string(6) "Clouds" ["description"]=&gt; string(16) "scattered clouds" ["icon"]=&gt; string(3) "03d" } } ["sys"]=&gt; object(stdClass)#8 (1) { ["population"]=&gt; int(0) } ["url"]=&gt; string(31) "http://openweathermap.org/city/" } } }
  </code></pre>