Grey Grey - 1 month ago 7
PHP Question

Can you skip a specific looping instance in a php loop?

Say, for example, I have these parameters set for a for loop:

$b = 5;
for ($a = 0; $a < $b; $a++) {
echo "Looped.";
}


Would there be a way to specifically target one of the looping instances (for this let's just say the 3rd loop) and skip it?

Answer

This will do the same as well.

$b = 5;  
for ($a = 0; $a < $b; $a++) { 
    if ($a != 3) {
        echo "Looped.";
    }
}