I have this bit of PHP code:
echo true ? 'a' : true ? 'b' : 'c';
The result of this:
b
But the expected result:
a
Since your code is evaluated as follows:
echo (true ? 'a' : true) ? 'b' : 'c';
this is equivalent to:
echo (true) ? 'b' : 'c';
Then the result is 'b'
'b'
ternary operator in php left associative.
You need to use
echo true ? 'a' : (true ? 'b' : 'c');