title: Traverse an STD Class object inside an array
body: <p>I've send an Array with data through FormData with Ajax. 
  I json encoded it first before sending it through and decoded it back at the PHP side. </p>
  
  <p>My problem is this: <code>"Trying to get property 'ID' of non-object"</code> Or <code>"Illegal string offset ID"</code></p>
  
  <p>which is weird, since my array is like:</p>
  
  <pre><code> array(7) {
   [0]=&gt;
   object(stdClass)#779 (2) {
      ["ID"]=&gt;
      string(1) "1"
      ["Value"]=&gt;
      string(19) "Onbeperkt helpdesk."
   }
   [1]=&gt;
   object(stdClass)#780 (2) {
      ["ID"]=&gt;
      string(1) "2"
      ["Value"]=&gt;
      string(43) "Een direct aanspreekpunt voor al uw vragen."
   }
   [2]=&gt;
   object(stdClass)#781 (2) {
      ["ID"]=&gt;
      string(1) "3"
      ["Value"]=&gt;
      string(20) "Een stabiel netwerk."
   }
   [3]=&gt;
   object(stdClass)#782 (2) {
      ["ID"]=&gt;
      string(1) "4"
      ["Value"]=&gt;
      string(43) "Uw belangrijke gegevens optimaal beveiligd."
   }
  }
  </code></pre>
  
  <p>The way I tried traversing the array:</p>
  
  <pre><code> $voordelen = json_decode($_POST['voordelen']);
                          echo var_dump($voordelen);
                          for ($i = 0; $i &lt; count($voordelen); $i++) {
                              foreach ($voordelen[$i] as $key =&gt; $item) {
                                  $voorArray = array(
                                      "id" =&gt; $item-&gt;ID,
                                      "item" =&gt; $item-&gt;Value,
                                      "content_id" =&gt; $content-&gt;id // variable from code not shown here.
                                  );
                              }
                          }
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>                            for ($i = 0; $i &lt; count($voordelen); $i++) {
                              foreach ($voordelen[$i] as $item) {
                                  $voorArray = array(
                                      "id" =&gt; $item-&gt;ID,
                                      "item" =&gt; $item-&gt;Value,
                                      "content_id" =&gt; $content-&gt;id // Variable from code not shown here.
                                  );
                              }
                          }
  </code></pre>
  
  <p>I also tried using <code>$var['value']</code> instead of <code>$var-&gt;value</code></p>
  
  <p>But now I'm at a loss. Any help would be appreciated.</p>