Based on the examples from this page, I have the working and non-working code samples below.
Working code using if statement:
if
if (!empty
The ternary operator is just a shorthand for and if/else block. Your working code does not have an else condition, so is not suitable for this.
The following example will work:
echo empty($address['street2']) ? 'empty' : 'not empty';