Switch Question...

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

 



Ok, dumb question, and i have tested, but I want to ensure that my tests
were accurate, and behavior is correct.

Ok, i have an integer, that based on what it is, does certain things...

switch ((int)$intval)
{
}

now, if i need to do something on a few of the numbers, then:
	case 0:
		# do nothing as strings will be (int) as 0
		break;
	case 1:
		# do this
		break;
	case 12:
		# do this
		break;
	default:
		# do everything that is general to this

which this works, as the $intval should never be anything that i am not
expecting as there is another part of the code that decides which int's
to send to this class.

but is there a better way to do this?   this could potentially do a lot
more, and be more dynamic, but there is also the possibilty that i need
to have more "custom" commands based on an integer value, and not
something that is "generic".

Is there a way to only do from like cases 2-11, without doing:
	case 2:
	case 3:
	case 4:
	.....
	case 11:
		# do this stuff
		break;


am I just overthinking things?  i dunno... it's monday...  brains still
on weekend mode.

Steve


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