continue not working

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I *MUST* be overlooking something obvious. Consider the following code:

        foreach($_POST as $key=>$value) {
                print "$key=>$value<br />";
                if(! empty($value)) {
                        switch($key) {
                                case "Submit":
                                case "keyList":
                                case "curKey":
                                        print "Matched exception<br />";
                        print "Didn't bypass.<br />";

Among the form display is:

        Matched exception
        Didn't bypass.

Obviously, the "switch" statement was properly matched as it shows it
matched the test expression. The next statement is a "continue", which
should have gone to the next statement in the loop, but it DIDN'T. It's as
if the "continue" statement was ignored. What am I missing?

Re: continue not working

On Sun, 26 Sep 2004 14:14:39 GMT, Michael Satterwhite

Quoted text here. Click to load it


continue is used within looping structures to skip the rest of the current loop
iteration and continue execution at the beginning of the next iteration.

    Note: Note that in PHP the switch statement is considered a looping
structure for the purposes of continue.

continue accepts an optional numeric argument which tells it how many levels of
enclosing loops it should skip to the end of.

 So "continue 2" to get out of the switch and also the enclosing loop?

< Space: disk usage analysis tool

Re: continue not working - THANKS

Andy Hassall wrote:

Quoted text here. Click to load it

Thanks. While I can't think of a rational reason that a switch should be
considered a loop, there is no rule that says I have to understand it. <g>

Appreciate the help.

Site Timeline