Looping through POST variables from Form : <p>I'm sure this is quite simple but all my searches have thrown up complicated answers that don't seem quite on point.</p>

<p>I have an array from a form and want to echo it back to a customer with an option to confirm the order.</p>

<p>The array looks like this:-</p>

<pre><code> POST:- Array
(
    [choice] =&gt; Array
        (
            [0] =&gt; Array
                (
                    [quantity] =&gt; 4
                    [price] =&gt; 7.50
                    [itemname] =&gt; Margherita Pizza
                    [merchant] =&gt; 3000
                    [itemid] =&gt; 2000
                )

            [1] =&gt; Array
                (
                    [quantity] =&gt; 2
                    [price] =&gt; 3.50
                    [itemname] =&gt; Garlic Bread
                    [merchant] =&gt; 3000
                    [itemid] =&gt; 2001
                )

        )

    [submit] =&gt; Submit
)
</code></pre>

<p>and the code I'm using to extract is:-</p>

<pre><code>    $_cp_i=0;
    foreach($_POST['choice'] as $mychoice) {
    $itemname[$_cp_i]=$mychoice['itemname'][$_cp_i];
    $quantity[$_cp_i]=$mychoice['quantity'][$_cp_i];
    $price[$_cp_i]=$mychoice['price'][$_cp_i];
    $_cp_i++;
    echo "&lt;tr&gt;&lt;td&gt;$itemname&lt;/td&gt;&lt;td&gt;$quantity[$_cp_i]&lt;/td&gt; 
&lt;td&gt;$price[$_cp_i]&lt;/td&gt;&lt;/tr&gt;";
}
</code></pre>

<p>The itemname just shows as Array and the other two fields are blank.</p>
