I have the following array:
$booking_array = array(
"2018-09-01"=>array("360","360","360"),
"2018-09-02"=>array("360","360"),
"2018-09-03"=>array("360","520"),
"2018-09-04"=>array("360","360"),
"2018-09-05"=>array("360","520","520"),
);
echo '<pre>',print_r($booking_array),'</pre>';
I want to get only the highest number of occurrences of a specific value in the whole array.
So for example the highest number of occurrences for "360" is "3", and for "520" it is "2".
I'm using array_count_values like so:
foreach($booking_array as $key => $val) {
print_r(array_count_values($val));
}
Which outputs:
Array
(
[360] => 3
)
Array
(
[360] => 2
)
Array
(
[360] => 1
[520] => 1
)
Array
(
[360] => 2
)
Array
(
[360] => 1
[520] => 2
)
But I don't understand how I can take the highest values only and transform this into:
Array
(
[0] => 360
[1] => 360
[2] => 360
[3] => 520
[4] => 520
)