Help regrouping an array
<p>I'd like to regroup my array. I have the following:</p>

<pre><code>Array
(
    [0] =&gt; Array
        (
            [name] =&gt; test1
            [item_id] =&gt; 1
            [category] =&gt; cat1
        )
    [1] =&gt; Array
        (
            [name] =&gt; test2
            [item_id] =&gt; 2
            [category] =&gt; cat1
        )
    [2] =&gt; Array
        (
            [name] =&gt; test3
            [item_id] =&gt; 3
            [category] =&gt; cat1
        )
    [3] =&gt; Array
        (
            [name] =&gt; test4
            [item_id] =&gt; 4
            [category] =&gt; cat2
        )
)
</code></pre>

<p>I'd like to regroup it like this:</p>

<pre><code>Array
(
    [cat1] =&gt; Array
        (
            [0] =&gt; Array
            (
                [name] =&gt; test1
                [item_id] =&gt; 1
            )
            [1] =&gt; Array
            (
                [name] =&gt; test2
                [item_id] =&gt; 2
            )
            [2] =&gt; Array
            (
                [name] =&gt; test3
                [item_id] =&gt; 3
            )
        )
    [cat2] =&gt; Array
        (
            [name] =&gt; test4
            [item_id] =&gt; 4
        )
)
</code></pre>

<p>Can someone tell me how this is best done?</p>
