PHP array new structure form with existing one
<p>I have a sql query that gives me array in following format. Basically the zeroth element is a event_id and the first element is a photo_id related to event. Following is the array </p>

<pre><code>Array
(
[0] =&gt; Array
    (
        [0] =&gt; 1
        [1] =&gt; 1
    )

[1] =&gt; Array
    (
        [0] =&gt; 1
        [1] =&gt; 2
    )

[2] =&gt; Array
    (
        [0] =&gt; 1
        [1] =&gt; 3
    )

[3] =&gt; Array
    (
        [0] =&gt; 0
        [1] =&gt; 4
    )

[4] =&gt; Array
    (
        [0] =&gt; 0
        [1] =&gt; 5
    )

[5] =&gt; Array
    (
        [0] =&gt; 1
        [1] =&gt; 6
    )

[6] =&gt; Array
    (
        [0] =&gt; 0
        [1] =&gt; 7
    )

[7] =&gt; Array
    (
        [0] =&gt; 1
        [1] =&gt; 8
    )

[8] =&gt; Array
    (
        [0] =&gt; 0
        [1] =&gt; 9
    )

[9] =&gt; Array
    (
        [0] =&gt; 1
        [1] =&gt; 10
    )

[10] =&gt; Array
    (
        [0] =&gt; 2
        [1] =&gt; 11
    )

[11] =&gt; Array
    (
        [0] =&gt; 2
        [1] =&gt; 12
    )

)
</code></pre>

<p>I need to covert all the zeroth element as key and the first element as value wrt to it. i.e. All the same event id has their own set of photos. So Output should like :</p>

<pre><code>array(
    [1]=&gt;[1,2,3,6,8,10]
    [0]=&gt;[4,5,7,9]
    [2]=&gt;[11,12]
</code></pre>

<p>Thanks !</p>
