Re: Multiple "if()" statements

From: Date: Thu, 29 Jun 2006 11:51:55 +0000
Subject: Re: Multiple "if()" statements
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-238906@lists.php.net to get a copy of this message
At 8:15 PM -0400 6/28/06, Robert Cummings wrote: >On Wed, 2006-06-28 at 20:02, David Tulloh wrote: >> Grae Wolfe - PHP wrote: >> > ... > > > want. Any help would be great! -snip- if/elseif -snip- <holy war id="opinion"> Whenever you need a elseif, then it's time to consider a switch -- like thus: print( "<tr>" ); switch $row[1] { case: "none"; print( "<td>$row[0] $row[2]</td>" ); break; case: $row[2]; print( "<td>$row[0] $row[2]</td>" ); break; default: print( "<td>$row[0] ($row[1]) $row[2]</td>" ); break; } print( "</tr>" ); <humor id="mine"> /* Please note the humor tags, smiley and apology beforehand. No offense meant to anyone -- insert apology where needed -- and appropriate. Your mileage may vary, Take only as prescribed by doctor's advice. No hablo inglés */ To me, the switch statement is so much simpler -- what's with you guys and these long-ass and confusing if/elseif structures? :-) </humor id="mine"> </holy war id="opinion"> tedd <limping off to his bear cave awaiting fallout/>. -- ------------------------------------------------------------------------------------ http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#238906) next »