I need to take sum of beds of unique date from array. I had tried with foreach but I am getting repeated data.
How can I get data like,
on 01.08.18 I have 3 bookings and sum of beds is 10
on 02.08.18 I have 3 bookings and sum of beds is 18
on 03.08.18 I have 2 bookings and sum of beds is 7
<?php
$dates = ['01.01.18', '02.01.18', '03.01.18']; //Dates are getting from daterange datepicker and preparing dates using php and stored in array.
foreach($dates as $date) {
// fetching data from table where date is matching with "$date".
$bookings = [
['date' => '01.01.18', 'beds' => '2'],
['date' => '01.01.18', 'beds' => '3'],
['date' => '01.01.18', 'beds' => '5'],
['date' => '02.01.18', 'beds' => '7'],
['date' => '02.01.18', 'beds' => '6'],
['date' => '02.01.18', 'beds' => '5'],
['date' => '03.01.18', 'beds' => '2'],
['date' => '03.01.18', 'beds' => '5'],
];
}
foreach($bookings as $booking) {
print_r($booking['date']);
}