View Single Post
Old 05-19-2009, 08:18 AM   #14 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
It may be worth adding that we can nest ternary operators.

It begins to get truly messy when you do this, and that's really when you should begin considering an if statement instead.

However:

php Code:
$szGender = 'M';
//$szGender = 'F';
//$szGender = '';

printf
(
    'Gender: %s',
    (
        !$szGender  ? 'Unknown'
                    : ($szGender == 'M'
                    ? 'Male'
                    : 'Female')
    )
);
Wow, I understand ternary operators, but here.. you just lost me :p Perhaps because I just woke up xD
__________________
Tanax is offline  
Reply With Quote