I have a huge array, which I loop with a foreach.
foreach ($items as $item) {
$sender = $item->getSender();
$id = $item->getId();
}
The $sender can be any string but different items ($item) can have the same string. That means in one foreach the $sender can have the same value. Now I want to store the ids ($id) in an array or something similiar for each $sender. So if $sender was “abcde” 3 times I want an array with 3 items and lets say $sender was “ztra” 2 times, I want to have an array with 2 ids for that as well.
So what I need is a collection of ids per sender, how could I do that?
Thanks!
should do the trick….