I have an array in PHP like the first one below and I want to merge all the subarrays having the same index key so that after merging they appear under one index key.Any help will be appreciated.THANKYOU
Array:
Array (
[person1] => Array (
[id] => 234
[acc] => 1
)
[person1] => Array (
[id] => 345
[acc] => 2
)
[person2] => Array (
[id] => 128
[acc] => 1
)
[person3] => Array (
[id] => 576
[acc] => 5
)
[person3] => Array (
[id] => 628
[acc] => 1
)
)
The Output should be like this:
Array
(
[person1] => Array
(
0 => Array
(
[id] => 234
[acc] => 1
),
1 => Array
(
[id] => 345
[acc] => 2
)
)
[person2] => Array
(
0 => Array
(
[id] => 128
[acc] => 1
)
)
[person3] => Array
(
0 => Array
(
[id] => 576
[acc] => 5
),
1 => Array
(
[id] => 628
[acc] => 1
)
)
)