Iterating part of array causes error
<p>I have some Json being returned from facebook which I'm then parsing in to an array using json _decode. The data ends up looking like this (this is just the snippet I'm interested in):</p>

<pre><code>( [data] =&gt;
     Array ( [0] =&gt; 
         Array ( 
             [id] =&gt; 1336269985867_10150465918473072 
             [from] =&gt; 
                 Array ( [name] =&gt; a name here 
                         [category] =&gt; Community 
                         [id] =&gt; 1336268295867 ) 
                         [message] =&gt; A message here
</code></pre>

<p>Now I've been able to iterate over this data and get what I need:</p>

<pre><code>   $jsonDecoded = json_decode($json, true);
   $xmlOutput = '&lt;?xml version="1.0"?&gt;&lt;data&gt;&lt;items&gt;';
   foreach ($jsonDecoded as $e) {
       foreach ($e as $i) {
           $xmlOutput .= '&lt;item&gt;&lt;timestamp&gt;' . $i['created_time'] . '&lt;/timestamp&gt;&lt;title&gt;&lt;![CDATA[ ' . $i['message'] .' ]]&gt;&lt;/title&gt;&lt;link&gt;' . $link . '&lt;/link&gt;&lt;type&gt;facebook&lt;/type&gt;&lt;/item&gt;';
       }
   }

   $xmlOutput .= '&lt;/items&gt;&lt;/data&gt;';
</code></pre>

<p>..up until now where I need to check on the from->id value. </p>

<p>I added this line in the second for each:</p>

<pre><code> foreach ($e as $i) {
     if($i['from']['id'] == '1336268295867') {
</code></pre>

<p>But this just gives me an error:</p>

<p><b>Fatal error</b>:  Cannot use string offset as an array in /Users/Desktop/Webs/php/getFeeds</p>

<p>Any ideas why? I'm sure this is the correct way to get at that value and in actual fact if I echo this out in my loop instead of doing the if statement above I get the value back:</p>

<pre><code>$jsonDecoded = json_decode($json, true);
$xmlOutput = '&lt;?xml version="1.0"?&gt;&lt;data&gt;&lt;items&gt;';
foreach ($jsonDecoded as $e) {
    foreach ($e as $i) {
       echo $i['from']['id']  
</code></pre>

<p>This returns me all of the from->id values in the code returned from facebook and then following this I get the error:</p>

<p>133626829985867133626829985867133626829985867133626829985867195501239202133626829985867133626829985867133626829985867133626829985867133626829985867<br />
<b>Fatal error</b>:  Cannot use string offset as an array in <b>/Users/Desktop/Webs/php/getFeeds.php</b> on line <b>97</b><br /> </p>

<p>(line 97 is the echo line)</p>
