I have 2 different possible values I use in an equation. I want to select whichever one exists and is greater using the least amount of code. It's possible neither variable exists, in which case year = 0, but one or both might exist. I.e:
if(isset($this->average['year'] || isset($this->Listings['year']) {
$year = whichever is greater of the above.
} else {
$year = 0;
}
It seems like there must be a shorter/ less messy way to do this than:
if (isset($this->average['year']) && ($this->average['year'] > $this->Listings['year']) {
$year = $this->average['year'];
} elseif( isset($this->Listings['year'])) {
$year = $this->Listings['year'];
} else {
$year = 0;
}
Thanks