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
I think you used the brackets the wrong way. Try this:
$test = (empty($address['street2']) ? 'Yes ' : 'No ');
I think it should work, you can also use:
echo (empty($address['street2']) ? 'Yes ' : 'No ');