I have a piece of code and I want to convert it to ternary operator. Can anyone help? It has 1 if and 2 else if conditions so I am having trouble converting it. Here is my code.
if ($this->session->data['desired_service']==1){
echo 'Home Delivery';
} else if ($this->session->data['desired_service']==2){
echo 'Take Away';
} else if ($this->session->data['desired_service']==3){
echo 'DinIN';
}
Here is the code that I have used so far.
$service = ( $this->session->data['desired_service']== 1 ) ? "Home Delivery" : ( $this->session->data['desired_service'] == 2 ) ? "Take Away" : ( $this->session->data['desired_service'] == 3 ) ? "DinIN";
But it is giving me a syntax error.