|
-
Feb 25th, 2004, 02:43 PM
#1
Thread Starter
Frenzied Member
switch statement [Resolved]
can you have multiple values in one case?
Last edited by ober0330; Feb 27th, 2004 at 08:08 AM.
-
Feb 25th, 2004, 03:08 PM
#2
try
PHP Code:
$chk = "blahblah";
$var = "ooga";
$var2 = "booga";
switch($chk){
case ($var || $var2):
echo "wiggy waggy woo";
break;
default:
echo "default";
}
-
Feb 26th, 2004, 05:02 PM
#3
Frenzied Member
you can't do that
working a bit around with it I found out that it is not possible to
compare the variable with two different values in one step like this
(system running a w2k server, apache2.0.43 & php430):
switch ($myvar) {
case ("foo" || "bar"): //do something
break;
case ("other"): //do another thing
break;
default:
}
rather use:
switch ($myvar) {
case ("foo"):
case ("bar"): //do something
break;
case ("other"): //do another thing
break;
default:
}
-
Feb 27th, 2004, 08:08 AM
#4
Thread Starter
Frenzied Member
Yeah, I actually used that instead. Falling through without breaks seems like the best method.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|