title: Facebook PHP 4.x return array parse
body: <p>Hey all I am just now getting around to the newest version of the PHP sdk for Facebook. It seems to use a new array of returned data that I can not seem to be able to parse out what I need and not all other gibberish it has contained inside the array.</p>
  
  <p>The array returned looks like this:</p>
  
  <pre><code>Array (
      [data] =&gt; Array (
          [0] =&gt; stdClass Object (
              [id] =&gt; 439676913452345546787863523525
              [name] =&gt; John Doe
              [picture] =&gt; stdClass Object (
                  [data] =&gt; stdClass Object (
                      [is_e] =&gt;
                      [url] =&gt; https://blah.com....
                  )
              )
          )
          [1] =&gt; stdClass Object (
              [id] =&gt; 56594790468026754634524674
              [name] =&gt; Bob Barker
              [picture] =&gt; stdClass Object (
                  [data] =&gt; stdClass Object (
                      [is_e] =&gt;
                      [url] =&gt; https://blah.com....
                  )
              )
          )
          [2]...etc etc...
          [paging] =&gt; stdClass Object ( 
              [cursors] =&gt; stdClass Object ( 
                  [before] =&gt; QWFMmhllXN5JH....Rk52QWc= 
                  [after] =&gt; WGHtdnNIwaDlRz....05RNB0E= 
              ) 
          )
      )
  )
  </code></pre>
  
  <p>In the older version of the Facebook SDK I just needed to do something along these lines (below code example is getting the <strong>id</strong> within the returned array and checking also to make sure it has a value or not):</p>
  
  <pre><code>foreach($theReturnedArray['data'] as $rData) {
    $id = (isset($rData['id']) ? $rData['id'] : null);
    $name = (isset($rData['name']) ? $rData['name'] : null);
  
    echo $name . ' ' . $id . '&lt;br /&gt;';
  }
  </code></pre>
  
  <p>in order to get the value that I needed. Now the return has an added <strong>stdClass object</strong> within the array itself and I am unsure on how to go about getting <em>id, name &amp; picture url</em> from it.</p>
  
  <p>Any help would be awesome!</p>
  
  <p><strong>ANSWER</strong></p>
  
  <p>It was caused of an error in my code that I was getting 0's back (the +):</p>
  
  <pre><code> echo $name . ' ' . $id + '&lt;br /&gt;';
  </code></pre>
  
  <p>And I needed to change it to:</p>
  
  <pre><code> echo $name . ' ' . $id . '&lt;br /&gt;';
  </code></pre>
  
  <p>and the full code together:</p>
  
  <pre><code> foreach($graphObject['data'] as $rData) {
      $id = (isset($rData-&gt;id) ? $rData-&gt;id : null);
      $name = (isset($rData-&gt;name) ? $rData-&gt;name : null);
      $picUrl = (isset($rData-&gt;picture-&gt;data-&gt;url) ? $rData-&gt;picture-&gt;data-&gt;url : null);
  
      echo $id . '&lt;br/&gt;';
      echo $name . '&lt;br/&gt;';
      echo $picUrl . '&lt;br/&gt;';
      echo '======================================&lt;br/&gt;';
   }
  </code></pre>