Switch($a) { Case 1: Dowhatyouwant(); Case 2: Dowhatyouwant(); Default: Dowhatyouwant(); } -----Original Message----- From: Barry [mailto:barry@xxxxxxxxxxxxxx] Sent: Monday, June 12, 2006 5:12 PM To: php-general@xxxxxxxxxxxxx Subject: Re: Short writage of clauses Jochem Maas schrieb: > I find a switch statement sometimes handy for creating a 'truth table' > like you describe (I sometimes find it easier to read and/or add 'if' clauses): > > switch (true) { > case ($grandmaAge >= $tableAge): > case ($grandmaAge < $houseAge): > case ($grandmaAge == array_sum($grandKids)): > bakeCookie(); > break; > default: > haveABeer(); > watchFootball(); > } > > functionally the above could just as well be an if statement - it's pretty much > a question of personal preference. > Yeah true, it is better to view. Is it the same as the if i stated? (the grandma one) it's one if but not multiple ones (if elseif elseif .. etc.) The problem still is it's not that "short" ;) Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php