What I want to accomplish is this:
switch ($id)
{
case 1:
blah;
break;
case 2:
blah blah;
break;
case (($id > 3)&&($id < 9)):
blah blah blah;
break;
default:
sigh;
break;
}
So if $id = 1 then blah code is executed, if $id=2 then blah blah, and if $id is 4,5,6,7,8 then blah blah blah, otherwise sigh. (In my real situation the parameters are 5 and 2000 so I can't list them all seperately.) I can't seem to figure out how to get that two stage comparison. I've tried
case ($id >3) && ($id < 9)
case (9 > $id < 3)
but nothing works. Is this complex comparison possible in php case switch? Do I need to use a series of else ifs?
Thanks.
George K
switch ($id)
{
case 1:
blah;
break;
case 2:
blah blah;
break;
case (($id > 3)&&($id < 9)):
blah blah blah;
break;
default:
sigh;
break;
}
So if $id = 1 then blah code is executed, if $id=2 then blah blah, and if $id is 4,5,6,7,8 then blah blah blah, otherwise sigh. (In my real situation the parameters are 5 and 2000 so I can't list them all seperately.) I can't seem to figure out how to get that two stage comparison. I've tried
case ($id >3) && ($id < 9)
case (9 > $id < 3)
but nothing works. Is this complex comparison possible in php case switch? Do I need to use a series of else ifs?
Thanks.
George K