PHP Continue Control Structure


Using PHP Continue

PHP continue is a 'control structure' that belongs to a group with other control structures such as if, else, while, foreach and more. Its main use is to skip something. A popular place you may encounter 'continue' is within a loop. When it is used within a loops, it is used to 'skip something'. The code belowe shows how it can be used to skip an item in an array.

$myarray = array(Pete,Sam,John);
foreach($myarray as $name) {
  if($name == Sam) {
    continue;
  }
  print $name."<br/>";
}

Output is:
Pete
John