I have an array that has a list of PID, Email and Client in a comma delimited array. I was wondering if there’s a way to parse the input array and generate a new array that has “Email” as the key and all unique PIDs for that email. Since the input array can have thousands of elements, I was wondering about the fastest approach.
Ex: Input Array (PID, Email, Client)
--------------------------------------
Array (
[0] => 10, abc@test.com,Gmail
[1] => 11, def@test.com,Gmail
[2] => 12, abc@test.com,Gmail
[3] => 13, def@test.com,Gmail
[4] => 14, xyz@test.com,Gmail
[5] => 15, def@test.com,Gmail
)
Ex: Output Array (with Email as the key):
---------------------------------------------
Array (
[abc@test.com] => (
[0] => 10
[1] => 12
),
[def@test.com] => (
[0] => 11
[1] => 13
[2] => 15
),
[xyz@test.com] => (
[0] => 14
)
)
Thanks
1 Answer