How do I skip an iteration in a While Loop

Hi,

How does one skip an iteration in a Php loop and jump to the next iteration.

To be exact say I have:

while ($result_chk_word = mysql_fetch_array($query_chk_word)) {

	$meta_id = $result_chk_word['id'];

           	if (in_array($meta_id, $shown_list) {
		//jumpt to next iteration
	}

            do_1();
            do_2();
            do_3();

}

Thank you.
Dean

I think you are looking for the keyword continue

cpradio ,

This continue
does not end the While Loop and will just end the current iteration and jump to the next iteration. Right?
If right, then that is what I am looking 4.

From the link:

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

So, yes, it does what you want.

Excellent.
Thanks. And have GR8 day :slight_smile:

while ($result_chk_word = mysql_fetch_array($query_chk_word)) {

Safer is…

while ($result_chk_word = mysql_fetch_array($query_chk_word) !== false) {

Even better is to move to PDO but that’s likely out of scope.

It might be “safer”, but will do the wrong thing. $result_chk_word will always be a boolean. You probably meant (note the extra parentheses):

while (($result_chk_word = mysql_fetch_array($query_chk_word)) !== false) {

I did