PHP - Tricky... array into columns, but in a specific order
<pre><code>&lt;?php

$combinedArray = array("apple","banana","watermelon","lemon","orange","mango");


        $num_cols = 3;

        $i = 0;
        foreach ($combinedArray as $r ){
            /*** use modulo to check if the row should end ***/
            echo $i++%$num_cols==0 ? '&lt;div style="clear:both;"&gt;&lt;/div&gt;' : '';
            /*** output the array item ***/
    ?&gt;
        &lt;div style="float:left; width:33%;"&gt;
    &lt;?php
            echo $r;
    ?&gt;
        &lt;/div&gt;
    &lt;?php
        }
    ?&gt;
    &lt;div style="clear:both;"&gt;&lt;/div&gt;
</code></pre>

<p>The above code will print out the array like this:</p>

<p><strong>apple --- banana --- watermelon</strong></p>

<p><strong>lemon --- orange --- mango</strong></p>

<p>However, I need it like this:</p>

<p><strong>apple --- watermelon --- orange</strong></p>

<p><strong>banana --- lemon --- mango</strong></p>

<p>Do you know how to convert this? Basically, each value in the array needs to be placed underneath the one above, but it must be based on this same structure of 3 columns, and also an equal amount of fruits per column/row (unless there was like 7 fruits there would be 3 in one column and 2 in the other columns.</p>

<p>Sorry I know it's confusing lol</p>
