title: Trouble With PHP and Nested Arrays
body: <p>I am having a hard time working with nested arrays using json_decode(). I am trying to get a list of team names. </p>
  
  <p>Here is the actual array: <a href="http://pastebin.com/eMqMcucN" rel="nofollow">http://pastebin.com/eMqMcucN</a></p>
  
  <p>If you look at the array, there are three teams. The first team contains data I do not need and is not complete (but I am able to get the team name). Its the nested array where teams have complete data thats getting me. What I would like to get is the two additional team names and ignore the first team as it has no nested arrays and no real details. However, I have no problem geting the first team name as it is not nested.</p>
  
  <p>Any help/direction would be greatly appreciated. Here is what I am currently using on the array above.</p>
  
  <p>The line "echo 'name: ' .  $sd->name;" throws an error of "Warning: Invalid argument supplied for foreach()". I have tried variations but no luck.</p>
  
  <pre><code>$obj=json_decode($json);
  $data = $obj-&gt;fantasy_content-&gt;users-&gt;{'0'}-&gt;user[1]-&gt;teams;
  $userguid = $obj-&gt;fantasy_content-&gt;users-&gt;{'0'}-&gt;user-&gt;{'0'};
  
  echo '&lt;pre&gt;'; 
  foreach($data as $d){
  
      $subdata = $d-&gt;team;
  
      foreach($subdata as $sd){
          echo 'name: ' .  $sd-&gt;name; //this line errors
      }
   }
  </code></pre>