I’ve been trying this all day!
How would I convert the top multidimensional array into the bottom.
Array (
[0] => Array ( [id] => 34 [email] => a@example.com )
[1] => Array ( [id] => 34 [email] => b@example.com )
[2] => Array ( [id] => 33 [email] => c@example.com )
[3] => Array ( [id] => 33 [email] => d@example.com )
[4] => Array ( [id] => 33 [email] => e@example.com )
)
Array (
[0]=>Array ([id] => 34 [email] => Array ([0]=> a@example.com [1]=>b@example.com )
[1]=>Array ([id] => 33 [email] => Array ([0]=> c@example.com [1]=>d@example.com [2]=>e@example.com)
)
Many thanks.
The first loop produces an array keyed off the id fields, and simply pushes each email address onto it. The second loop then takes that intermediate array and wraps another array around it for the 0,1,etc… keys.