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
Live24x7
Forum Contributor
Posts: 194 Joined: Sat Nov 19, 2011 9:32 am
Post
by Live24x7 » Sun Sep 09, 2012 10:31 pm
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
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Sun Sep 09, 2012 10:37 pm
No. Probably better to use ifs.
(#10850)
Live24x7
Forum Contributor
Posts: 194 Joined: Sat Nov 19, 2011 9:32 am
Post
by Live24x7 » Sun Sep 09, 2012 11:42 pm
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;
}