I have the following code which I am trying to add a or operation to it but I am getting an error. Cant see what may be wrong. I want to get if it is set and greater than 0
foreach($av as $day => $a) {
if(isset($price[$ro['Room']['id']][$r['Rate']['id']][$day]) || $price[$ro['Room']['id']][$r['Rate']['id']][$day] > 0) {
$arr_total += $price[$ro['Room']['id']][$r['Rate']['id']][$day];
} else {
$errors[] = "No Set Price for $day";
}
// nice !
if(isset($a[$ro['Room']['title']]) && $a[$ro['Room']['title']] < 1) {
$no_rooms = true;
}
}
Then I think you need && not || and if the argument in isset is "" it is considered as set. So initialize that value to null initially or use another check
foreach($av as $day => $a) {
if(isset($price[$ro['Room']['id']][$r['Rate']['id']][$day]) && $price[$ro['Room']['id']][$r['Rate']['id']][$day] > 0) {
$arr_total += $price[$ro['Room']['id']][$r['Rate']['id']][$day];
} else {
$errors[] = "No Set Price for $day";
}
// nice !
if(isset($a[$ro['Room']['title']]) && $a[$ro['Room']['title']] < 1) {
$no_rooms = true;
}
}
try it
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.