Array in database, use as variable
<p>I am making a prototype invoice thing for practice. I'm using CakePHP 3 and the items are always going to be different so associating them with rows in another table won't work. In each row I have a column named items and in that is an array such as:</p>

<pre><code>    array(
      array("Name" =&gt; "apples",
        "Desc" =&gt; "a fruit called apple",
        "Price" =&gt; "1"
      ),
      array("Name" =&gt; "orange",
        "Desc" =&gt; "oranges",
        "Price" =&gt; "2",
      ),
      array("Name" =&gt; "watermelon",
        "Desc" =&gt; "watermelon",
        "Price" =&gt; "6"
      )
);
</code></pre>

<p>I'm wanting to use that array to build a foreach loop to display all the items in the invoice.</p>

<pre><code>    foreach ($items as $i =&gt; $row) {

    echo $row['Name'] . $row['Price'] . $row['Desc'] . "&lt;br&gt;";
}
</code></pre>

<p>I'm trying to use this method to get the data in from the column</p>

<pre><code>&lt;?php $items = $billing-&gt;items; ?&gt;
</code></pre>

<p>However this is what I receive: </p>

<pre><code>Warning (2): Invalid argument supplied for foreach() [APP/Template\Billing\invoice.ctp, line 56]
</code></pre>

<p>If I try to echo the data, it echo's it just fine. I don't understand why I can't make it a variable.</p>

<pre><code>&lt;?= h($billing-&gt;items); ?&gt;
</code></pre>