Switch Case jumping between two cases

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Live24x7
Forum Contributor
Posts: 194
Joined: Sat Nov 19, 2011 9:32 am

Switch Case jumping between two cases

Post by Live24x7 »

Hi

Is it possible to jump from one case to another ?
if so how?

I want to do something like this

Code: Select all

switch(situation){
          case 'a':
                 //..
          break;
          case 'b':
                if (condition x) goto case a
                if (condition y) goto case c
           break;
          case 'c':
                 //..
          break;
              
}
thanks a lot
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Switch Case jumping between two cases

Post by Christopher »

No. Probably better to use ifs.
(#10850)
Live24x7
Forum Contributor
Posts: 194
Joined: Sat Nov 19, 2011 9:32 am

Re: Switch Case jumping between two cases

Post by Live24x7 »

thnks given that i had 16 cases to evaluate, i stayed with switchcase. Just defined functions for caseA and caseC and the code now looks like:

Code: Select all

switch(situation){
          case 'a':
                 caseA();
          break;
          case 'b':
                if (condition x) caseA();
                if (condition y) caseC()
           break;
          case 'c':
             caseC();
          break;
             
}
Post Reply