Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tuanpt-0634
Created August 7, 2020 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuanpt-0634/00da87439e53c8d215257717a5edfade to your computer and use it in GitHub Desktop.
Save tuanpt-0634/00da87439e53c8d215257717a5edfade to your computer and use it in GitHub Desktop.
PHP for, switch continue
<?php
function writeLine($message)
{
echo $message . PHP_EOL;
}
$values = [1, 2, 42, 3];
foreach ($values as $value) {
switch ($value) {
case 1:
writeLine('Number one!');
break;
case 42:
writeLine('Life is 42');
continue;
default:
writeLine('Value is ' . $value);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment