Created
August 7, 2020 11:47
-
-
Save tuanpt-0634/00da87439e53c8d215257717a5edfade to your computer and use it in GitHub Desktop.
PHP for, switch continue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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