To do this you would use multiple nested case statments and break only after
the last case statement. You cannot use conditionals within a case
statement but this has the effect of an OR condition...
switch($color)
{
case "black": case 1:
return ImageColorAllocate($image,0,0,0);
break;
//.. etc.. //
}
Hope that helps.
- Kevin
----- Original Message -----
From: "Van Andel, Robbert" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 3:48 PM
Subject: [PHP] Switch Question
I'm trying to make a switch statement that looks for more than one possible
value. Something similar to:
switch($color)
{
case "black" || "1":
return ImageColorAllocate($image,0,0,0);
break;
case "white" || "2":
return ImageColorAllocate($image,255,255,255);
break;
case "gray" || "3":
return ImageColorAllocate($image,200,200,200);
break;
}
This is not working however, since all my colors are now black (it worked
before I add the number portion of the case statement.
First off, is this even possible to do, or do I need to make a seperate case
for the numbers. If it is possible, how do I make it work?
Robbert van Andel
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php