# 😎 how to use multiple ternary operator in php, ?:, ?? (ok)

```
<?php
$foo = 2;
$bar = ($foo == 1) ? "1" : (($foo == 2)  ? "2" : "other");
echo $bar;
?>
```

<figure><img src="https://929787348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRtlBk287z48lyi_B98%2Fuploads%2FQCFtmJ9JGxLtqTPbhi4L%2Fimage.png?alt=media&#x26;token=81490c7c-3698-4bed-a970-e9fbf822a95d" alt=""><figcaption></figcaption></figure>
