title: PHP/FB API/GRAPH - Why am I getting an undefined offset error?
body: <p>I dont understand why I get this error:</p>
  
  <blockquote>
    <p>Notice:  Undefined offset: 0</p>
  </blockquote>
  
  <p>Im trying to get a list of a users friends from the FB Graph API using:</p>
  
  <pre><code>// get users friends
          $friends_url = "https://graph.facebook.com/".$user_id."/friends?access_token=".$access_token;
          $friends_json = file_get_contents($friends_url);
          $friends_data = json_decode($friends_json, true);       
  
          for ($i = 0; $i &lt; sizeof($friends_data); $i++) {
          $friends = $friends_data[$i];
          echo $friends['name'] . ", ";
          }         
  </code></pre>
  
  <p>If you var_dump($friends_data) or print_r($friends_data) you can see that Ive got the array of friends, and that data[0] has a friends info. So why the error?</p>