Re: [PHP] alter switch variable inside case?

2002-08-31 Thread @ Edwin
Actually, you can--just don't "break;". Try it. - E I'd like to be able to modify the switch variable inside a case statement, like this: switch ($foo) { case 'step2': do_step2(); if ($error) $foo='step1'; //repeat step1 break; case 'step1': do_step1(); break;

Re: [PHP] alter switch variable inside case?

2002-08-31 Thread Joe Janitor
If you don't break, it continues to execute all the code until the end of the switch, ignoring any subsequent case statements. In my example, eliminating the break after step2 would cause execution of do_step1(), but also do_something_else(), which is not desired. --- @ Edwin [EMAIL PROTECTED]

Re: [PHP] alter switch variable inside case?

2002-08-31 Thread @ Edwin
Well, you don't have to take away all the "break;". :) For example, only here: switch ($foo) { case 'step2': do_step2(); if ($error) $foo='step1'; //repeat step1 break; - E If you don't break, it continues to execute all the code until the end of the switch, ignoring any

Re: [PHP] alter switch variable inside case?

2002-08-31 Thread Joe Janitor
Regardless of how many break statements you take away (even if only 1), case statements appear to be ignored after the first match is made. I need a way to make the switch statement continue evaluating case-matches, even after the first case match is made. Further, it should allow one case

Re: [PHP] alter switch variable inside case?

2002-08-31 Thread @ Edwin
It seems like you can do something like this: switch ($foo) { case 'a': if (do_a()) echo "a was done"; else print_menu(); // changes here break; case 'b': if (do_b()) echo "b was done"; else print_menu(); // changes here break; case 'menu': print_menu();