title: Displaying JSON data with PHP
body: <p>I have the following array</p>
  
  <pre><code>"forecast":{
      "txt_forecast": {
      "date":"11:00 PM EDT",
      "forecastday": [
      {
      "period":0,
      "icon":"partlycloudy",
      "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
      "title":"Saturday",
      "fcttext":"Partly cloudy in the morning, then mostly cloudy. High of 88F. Winds from the South at 5 to 10 mph.",
      "fcttext_metric":"Partly cloudy in the morning, then mostly cloudy. High of 31C. Winds from the South at 10 to 15 km/h.",
      "pop":"0"
      }
      ,
      {
      "period":1,
      "icon":"partlycloudy",
      "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
      "title":"Saturday Night",
      "fcttext":"Overcast in the evening, then partly cloudy. Low of 64F. Winds less than 5 mph.",
      "fcttext_metric":"Overcast in the evening, then partly cloudy. Low of 18C. Winds less than 5 km/h.",
      "pop":"10"
      }
  </code></pre>
  
  <p>How would I display the information in PHP? It goes all the way up to period 7.</p>
  
  <p>EDIT: Here is my edited code that is not working.</p>
  
  <pre><code>&lt;?php
  $json_string =    file_get_contents("http://api.wunderground.com/api/7ec5f6510a4656df/geolookup/forecast/q/40121.json");
  $parsed_json = json_decode($json_string);
  $temp = $parsed_json-&gt;{'forecast'}-&gt;{'txt_forecast'}-&gt;{'date'};
  $title = $parsed_json-&gt;{'forecast'}-&gt;{'txt_forecast'}-&gt;{'forecastday'}-&gt;{'title'};
  $for = $parsed_json-&gt;{'forecast'}-&gt;{'txt_forecast'}-&gt;{'forecastday'}-&gt;{'fcttext'};
  echo "Current date is ${temp},  ${title}: ${for}\n";
  
  foreach($parsed_json['forecast']['forecastday[0]'] as $key =&gt; $value)
  {
     echo $value['period'];
     echo $value['icon'];
     // etc
  }
  ?&gt;
  </code></pre>