title: How to loop a foreach on an object/array
body: <p>My <code>DB</code> returns an array of objects with arrays within.</p>
  <h1>Var_dump</h1>
  <pre><code>array (size=2)
    0 =&gt; 
      object(stdClass)[22]
        public 'customer_id' =&gt; string '10' (length=2)
        public 'cart' =&gt; string 'a:1:{s:32:&quot;f9bb1d342b1c2a0bfe982ef405369ec0&quot;;a:9:{s:5:&quot;rowid&quot;;s:32:&quot;f9bb1d342b1c2a0bfe982ef405369ec0&quot;;s:2:&quot;id&quot;;s:9:&quot;101_30524&quot;;s:3:&quot;qty&quot;;s:1:&quot;1&quot;;s:5:&quot;price&quot;;s:5:&quot;104.5&quot;;s:4:&quot;name&quot;;s:13:&quot;Business Card&quot;;s:5:&quot;image&quot;;s:18:&quot;business-cards.gif&quot;;s:4:&quot;ship&quot;;a:3:{s:6:&quot;Ground&quot;;d:9.730000000000000426325641456060111522674560546875;s:11:&quot;2nd Day Air&quot;;d:18.53999999999999914734871708787977695465087890625;s:9:&quot;Overnight&quot;;d:26.269999999999999573674358543939888477325439453125;}s:7:&quot;options&quot;;a:2:{s:17:&quot;Print Description&quot;;s:16'... (length=761)
        public 'shipping_type' =&gt; string 'Ground' (length=6)
        public 'shipping_cost' =&gt; string '9.73' (length=4)
        public 'order_sub_total' =&gt; string '104.50' (length=6)
        public 'order_total' =&gt; string '114.23' (length=6)
        public 'id' =&gt; string '28' (length=2)
        public 'timestamp' =&gt; string '2012-10-12 20:10:30' (length=19)
    1 =&gt; 
      object(stdClass)[23]
        public 'customer_id' =&gt; string '10' (length=2)
        public 'cart' =&gt; string 'a:2:{s:32:&quot;22d2d3d8584f6e0819c4e46af4d2fda2&quot;;a:9:{s:5:&quot;rowid&quot;;s:32:&quot;22d2d3d8584f6e0819c4e46af4d2fda2&quot;;s:2:&quot;id&quot;;s:9:&quot;101_94980&quot;;s:3:&quot;qty&quot;;s:1:&quot;1&quot;;s:5:&quot;price&quot;;s:2:&quot;64&quot;;s:4:&quot;name&quot;;s:13:&quot;Business Card&quot;;s:5:&quot;image&quot;;s:18:&quot;business-cards.gif&quot;;s:4:&quot;ship&quot;;a:3:{s:6:&quot;Ground&quot;;d:9.730000000000000426325641456060111522674560546875;s:11:&quot;2nd Day Air&quot;;d:18.53999999999999914734871708787977695465087890625;s:9:&quot;Overnight&quot;;d:26.269999999999999573674358543939888477325439453125;}s:7:&quot;options&quot;;a:2:{s:17:&quot;Print Description&quot;;s:164:&quot;'... (length=1506)
        public 'shipping_type' =&gt; string 'Ground' (length=6)
        public 'shipping_cost' =&gt; string '19.46' (length=5)
        public 'order_sub_total' =&gt; string '148.25' (length=6)
        public 'order_total' =&gt; string '167.71' (length=6)
        public 'id' =&gt; string '29' (length=2)
        public 'timestamp' =&gt; string '2012-10-12 20:29:10' (length=19)
  </code></pre>
  <p>Notice <code>cart</code> is a multidimensional array. How do I loop through these objects and arrays and create a table?</p>
  <pre><code>&lt;?php foreach($all_orders as $key =&gt; $val) : ?&gt;
  
      &lt;?php echo $key; ?&gt;  &lt;?php echo $val; ?&gt;
  
  &lt;?php endforeach; ?&gt;
  </code></pre>
  <p>This causes the following error: <em>A PHP Error was encountered Severity: 4096 Message: Object of class stdClass could not be converted to string</em></p>