I want to use ternary operator for if-elseif-else. But it is not working for me.
Kindly check the code below:
$openMon = "00:01"; // The below Line Returns Time
$openMon = "00:00"; // The below Line Returns Close
<td><?=(($openMon == '00:00')?'Close':date("g:i a", strtotime($openMon)));?></td>
The above line working perfectly because it returns True or false.
But when $openMon blank it returns 1am. I want when $openMon blank it returns "-"
I want Three Things in one line like:
$openMon = ""; // This is I want in ternary operator with above two conditions
if($openMon == "" ){
$openMon ="-";
}
I tried:
<td><?=isset((openMon == "")?'-':(($openMon == '00:00')?'Close':date("g:i a", strtotime($openMon)));?></td>
This is not working for me.
Basically I want in ternary operator:
if($openMon == ''){
$openMon = "-";
}else{
if($openMon == '00:00'){
$openMon = "Close";
}else{
$openMon = date("g:i a", strtotime($openMon)));
}
}
Any Idea or suggestions would be helpful.