Help with PHP arrays and foreach
<p>Hey guys. I'm building a simple blog and have my data returning from my database in an array. I want to show the comments associated with each blog post but I'm not sure how to organize this in a loop. This is my array:</p>

<pre><code>Array
(
    [author] =&gt; Administrator
    [post] =&gt; Testing entry number one
    [entry_date] =&gt; Fri, 23 Oct 2009
    [commenter] =&gt; Sally Anderson
    [comments] =&gt; comment 1 post 1
    [comment_date] =&gt; October 24th, 2009 at 5:24 AM
    [blog_id] =&gt; 1
)
Array
(
    [author] =&gt; Administrator
    [post] =&gt; Testing entry number two
    [entry_date] =&gt; Sat, 24 Oct 2009
    [commenter] =&gt; Sally Anderson
    [comments] =&gt; comment 1 post 2
    [comment_date] =&gt; October 24th, 2009 at 5:21 AM
    [blog_id] =&gt; 2
)
Array
(
    [author] =&gt; Administrator
    [post] =&gt; Testing entry number one
    [entry_date] =&gt; Fri, 23 Oct 2009
    [commenter] =&gt; Mike
    [comments] =&gt; comment 2 post 1
    [comment_date] =&gt; October 24th, 2009 at 5:21 AM
    [blog_id] =&gt; 1
)
Array
(
    [author] =&gt; Administrator
    [post] =&gt; Testing entry number two
    [entry_date] =&gt; Sat, 24 Oct 2009
    [commenter] =&gt; Mike
    [comments] =&gt; comment 2 post 2
    [comment_date] =&gt; October 24th, 2009 at 5:21 AM
    [blog_id] =&gt; 2
)
</code></pre>

<p>Notice that each post repeats based on the number of comments associated with it. In this particular case this array has 2 comments associated with each post. Could someone please help me write a foreach loop that will output 2 posts with the correct comments for each one?</p>

<p>Thanks!</p>

<p><hr /></p>

<p>Maybe I'm not explaining well enough. Here is what I am looking for.</p>

<pre><code>Array
(
    [author] =&gt; Administrator
    [post] =&gt; Testing entry number one
    [entry_date] =&gt; Fri, 23 Oct 2009
    [commenter] =&gt; Sally Anderson
    [comments] =&gt; 
        **[0] =&gt; Array
        (
           comment 1 post 1
           comment 2 post 1
        )**
    [comment_date] =&gt; October 24th, 2009 at 5:24 AM
    [blog_id] =&gt; 1
)
</code></pre>
