Re: Multiple "if()" statements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux