You have:
- an array with
$adults, where each $adult is object with thedate and theadults properties.
Now you want to make $groupedAdults, which will be array using thedate property as key. So the logic could look like this:
- foreach (
$adults as $adult):
$date = $adult->thedate
- check if
array_key_exists($date, $groupedAdults)
- if no, copy current
$adult to $groupedAdults[$date]
- if yes, add
$adult->theadults to the $groupedAdults[$date]->adults
Give it a try, hopefully you will be able to write it on your own now.