You need some parentheses around the right hand operand:
$foo = 1;
$bar = ( $foo == 1 ) ? "1" : (( $foo == 2 ) ? "2" : "other");
echo $bar;
PHP's interpreter is broken, and treats your line:
$bar = ( $foo == 1 ) ? "1" : ( $foo == 2 ) ? "2" : "other";
as
$bar = (( $foo == 1) ? "1" : ( $foo == 2)) ? "2" : "other";
and since that left hand expression evaluates as "true" the first operand of the remaining ternary operator ("2") is returned instead.