The problem is that PHP, unlike all other languages, makes the conditional operator left associative. This breaks your code – which would be fine in other languages.
You need to use parentheses:
$bar = $foo == 1 ? "1" : ($foo == 2 ? "2" : "other");
(Notice that I’ve removed the other parentheses from your code; but these were correct, just redundant.)