Re: Two cases going to same case?
| From: | Steve Edberg | Date: | Sun, 30 Jun 2002 09:48:08 +0000 |
| Subject: | Re: Two cases going to same case? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-104559@lists.php.net to get a copy of this message | ||
At 5:18 AM -0400 6/30/02, Leif K-Brooks wrote:
I have a switch in a script I'm working on. I need to have case 1 and 2 both to to case 3, but without case 1 going through case 2. Is this possible?No, but you can do it this way: switch ($foo) { case 1:
...
do_something();
break;
case 2:
...
do_something();
break;
case 3:
do_something();
break;
}
function do_something() {
# this is the stuff that you want to do that is common to your
# cases 1, 2 and 3
}
This accomplishes the same thing.
-steve
--
+------------------------------------------------------------------------+
| Steve Edberg sbedberg@ucdavis.edu |
| University of California, Davis (530)754-9127 |
| Programming/Database/SysAdmin http://pgfsun.ucdavis.edu/ |
+------------------------------------------------------------------------+
| The end to politics as usual: |
| The Monster Raving Loony Party (http://www.omrlp.com/) |
+------------------------------------------------------------------------+