Skip to content

Instantly share code, notes, and snippets.

@YurePereira
Created May 26, 2017 19:54
Show Gist options
  • Select an option

  • Save YurePereira/4c2c3afcf3aa0a3ff0d46dbc70dac79b to your computer and use it in GitHub Desktop.

Select an option

Save YurePereira/4c2c3afcf3aa0a3ff0d46dbc70dac79b to your computer and use it in GitHub Desktop.
Usando o comando break no laço while e for.
<?php
$contador1 = 0;
while (true) {
echo 'Laço 1: ' . $contador1 . PHP_EOL;
for ($contador2 = 0; $contador2 < 5; $contador2++) {
if ($contador1 === 2) {
break 2;
}
echo 'Laço 2: ' . $contador2 . PHP_EOL;
}
$contador1++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment