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
Array
(
[0] => Array
(
[0] => 1
[1] => 1
)
[1] => Array
(
[0] => 1
[1] => 2
)
[2] => Array
(
[0] => 1
[1] => 3
)
[3] => Array
(
[0] => 0
[1] => 4
)
[4] => Array
(
[0] => 0
[1] => 5
)
[5] => Array
(
[0] => 1
[1] => 6
)
[6] => Array
(
[0] => 0
[1] => 7
)
[7] => Array
(
[0] => 1
[1] => 8
)
[8] => Array
(
[0] => 0
[1] => 9
)
[9] => Array
(
[0] => 1
[1] => 10
)
[10] => Array
(
[0] => 2
[1] => 11
)
[11] => Array
(
[0] => 2
[1] => 12
)
)
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 :
array(
[1]=>[1,2,3,6,8,10]
[0]=>[4,5,7,9]
[2]=>[11,12]
Thanks !
1 Answer