php for loop skip to next code example

Example 1: for loop php continue to next item

$stack = array('first', 'second', 'third', 'fourth', 'fifth');

foreach($stack as $v){
    if($v == 'second') {
      continue;
    }
    echo $v.'<br>';
}
/*
first
third
fourth
fifth
*/

Example 2: php skip loop

for ($i=0; $i <= 12; $i++) {
  if($1 == 5){
  	continue;
  }
  //code block
  
  //code block ends
}

Example 3: php continue

<?php
for ($i = 0; $i < 5; ++$i) {
    if ($i == 2)
        continue
    print "$i\n";
}
?>

Example 4: php for next loop step

for ($i = 0; $i < 10; ++$i) 
{
  echo "I will loop 10 times";
}