This line would produce that code without using if/else statements (even though ternery operator are really syntactic sugar around if/else statements)
$salary = max(0,$data['min_salary']) . ' TO ' . ($data['max_salary'] > 0 ? $data['max_salary'] : '*');
You don't really want the same scripting for both values as one should fallback to 0
and the other to *
. The problem with isset()
:
(isset($data['min_salary']) ? $data['min_salary'] : 0)
is that a variable can be set to an empty string $data = ''
which would return true
. I'd hazard you do not want this to happen.