I have this Array
Array
(
[2014-08-14] => Array
(
[18:00:00] => Array
(
[6] => Array
(
[price] => 15.36
[avail_clean] => 5
[avail_noclean] => 6
)
[7] => Array
(
[price] => 17.35
[avail_clean] => 2
[avail_noclean] => 3
)
)
[19:00:00] => Array
(
[6] => Array
(
[price] => 15.36
[avail_clean] => 5
[avail_noclean] => 6
)
[7] => Array
(
[price] => 17.35
[avail_clean] => 2
[avail_noclean] => 3
)
)
)
)
How can I get the following for 6 & 7 seperately: - Sum of price - max of avail_clean - max of avail_noclean
I got that far for the price:
foreach ($bookable as $date=>$key) {
foreach ($key as $time=>$key2) {
foreach($key2 as $room=>$key3){
foreach($key3 as $price=>$key4){
if($price == "price"){
if(isset($sumRoom[$room]['total'])){
$sumRoom[$room]['total'] += $key4;
}else{
$sumRoom[$room]['total'] = $key4;
}
}
}
}
}
}
Gives me this
Array(
[6] => Array
(
[total] => 30,72
)
[7] => Array
(
[total] => 34,7
)
)
But what about the max(), where should I put that?
avail_cleanandavail_nocleannumber?, you already got you sum, should be the same path, if not initialized assign it, then under the loop just check if the current number is higher, if yes then reassignavail_cleanandavail_cleanthen usemax()