How can I make an array when there are duplicate values?
<p>I have data that contains links for a navigation bar. It should be structured exactly like an unordered list, with a header and then all of the corresponding links below that header. I cannot seem to build this correctly. This would be some sample data from the database.</p>

<pre><code>HEADING     LIST         LINK
Favs     google   http://...
Favs     yahoo   http://...
Favs     stackoverflow http://...
Site     first link  http://...
Site     second link  http://...
</code></pre>

<p>This data should then <strong>group</strong> all of the headings into one and then display the links associated with them. Is this even possible or maybe there is a better way?</p>

<p>I plan to use the "HEADING" and "LIST" to dynamically build a <code>&lt;UL&gt;</code> type of menu.</p>

<p><hr /></p>

<p>Well, this isn't working as I had hoped. Here is the array that is being built from the database. Notice how sidebar[0] and sidebar[1] rpeat the value "Favs". This will repeat the same value on my form which I don't want. All of the duplicate names should be grouped together. Is this possible?</p>

<pre><code>Array
(
    [date] =&gt; Sun, 25 Oct 2009
    [sidebar] =&gt; Array
        (
            [0] =&gt; Array
                (
                    [Favs] =&gt; Array
                        (
                            [author_sidebar_link] =&gt; google.com
                        )

                )

            [1] =&gt; Array
                (
                    [Favs] =&gt; Array
                        (
                            [author_sidebar_link] =&gt; yahoo.com
                        )

                )

            [2] =&gt; Array
                (
                    [Offsite] =&gt; Array
                        (
                            [author_sidebar_link_title] =&gt; something
                        )

                )

            [3] =&gt; Array
                (
                    [Something] =&gt; Array
                        (
                            [author_sidebar_link] =&gt; something else
                        )
                )
        )
)
</code></pre>
