php array display two titles at a time
<p>I've got an array of 28 titles and i need to run through the array and display 2 items(titles) at a time into the following html:</p>

<pre><code>&lt;ul&gt;
    //start loop here for all items in array
    &lt;li&gt;
        //display two titles in seperate divs
        &lt;div class="item1"&gt;
            &lt;h1&gt;title[x]&lt;/h1&gt;
        &lt;/div&gt;
        &lt;div class="item2"&gt;
            &lt;h1&gt;title[x]&lt;/h1&gt;
        &lt;/div&gt;
    &lt;/li&gt;
    //repeat...
&lt;/ul&gt;
</code></pre>

<p>So basically it outputs like the following:</p>

<pre><code>&lt;ul&gt;
    &lt;li&gt;
        &lt;div&gt;
            &lt;h1&gt;Title 1&lt;/h1&gt;
        &lt;/div&gt;
        &lt;div&gt;
            &lt;h1&gt;Title 2&lt;/h1&gt;
        &lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;div&gt;
            &lt;h1&gt;Title 3&lt;/h1&gt;
        &lt;/div&gt;
        &lt;div&gt;
            &lt;h1&gt;Title 4&lt;/h1&gt;
        &lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;div&gt;
            &lt;h1&gt;Title 5&lt;/h1&gt;
        &lt;/div&gt;
        &lt;div&gt;
            &lt;h1&gt;Title 6&lt;/h1&gt;
        &lt;/div&gt;
    &lt;/li&gt;
    //etc..
&lt;/ul&gt;
</code></pre>

<p>This is what I've tried so far, obviously it just duplicated both titles.</p>

<pre><code>&lt;div id="work-list"&gt;

    &lt;ul class="work-list-cat group"&gt;

    &lt;?php if (!empty($this-&gt;intro_items)) { 

    foreach($this-&gt;intro_items as $id =&gt; $item) {
        $itemarray[] = $item;
    }

    $count = count($itemarray);

    $item = 1;

    for($y = 0; $y &lt; $count; $y++) {
    ?&gt;

    &lt;li style="width:33.333333333333333333333333333333%; height:100%; float:left;"&gt;

        &lt;?php 
                for($x=0; $x&lt;$item; $x++){ ?&gt;
                &lt;div style="width:100%; height:50%; float:left; background-color:#333;"&gt;
                &lt;?php echo $itemarray[$y]-&gt;title; ?&gt;
                &lt;/div&gt;
                &lt;div style="width:100%; height:50%; float:left; background-color:#444;"&gt;
                &lt;?php echo $itemarray[$y]-&gt;title; ?&gt;
                &lt;/div&gt;
            &lt;?php   } ?&gt;
    &lt;/li&gt;

    &lt;?php } ?&gt;

    &lt;?php } ?&gt;

    &lt;/ul&gt;

&lt;/div&gt;  &lt;?php //End of #work-list ?&gt;
</code></pre>
