Re: IF or SWITCH

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

 



Chris wrote:
Ray Hauge wrote:

Hello World! wait, not coding... (sorry, long night)


...

if ($count_lenders > 1)....

I would take it even further and setup a load of variables that hold the
boolean states that you what to check in the 50 odd if/else statements...

something like:

$ffelpEQtotal    = ($numFFELP == $numTotal);
$ffelptotEQtotal = (($enumFFELP + $numFFELP) == $numTotal);
$countlenders    = count($FFELP_Lenders);
$lendersGTone    = $countlenders > 1;

I would do this purely for readability in the if/else statements (i.e. so I could
keep them as short as possible.) this is assuming the boolean states you are checking
are quite repetitive (although the combination changes each time)

and I would personally probably write it up as a switch statement
because I feel it looks 'nicer' and it's more compact, thats down to personal
opinion of course. something like:

switch (true) {
	case $ffelpEQtotal && $lendersGTone:		
		return array(true, 'A');
	case $ffelptotEQtotal:		
		return array(true, 'A');
	// weeeeeee! etc :-)
}

<disclaimer>
some people consider this use of switch to be a complete
misuse - be careful with things that autocast cast to true - know what
you're doing :-)
</disclaimer>

--
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