Last active
November 10, 2020 21:27
-
-
Save kezzyhko/4761479fc97c9f5e3fce708c54e870bc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| const WORDS = [ | |
| 3 => 'Fizz', | |
| 5 => 'Buzz', | |
| // 2 => 'Vezz', | |
| ]; | |
| const N = 100; | |
| for ($i = 0; $i <= N; $i++) { | |
| $word_printed = false; | |
| foreach (WORDS as $number => $word) { | |
| if ($i % $number == 0) { | |
| echo $word; | |
| $word_printed = true; | |
| } | |
| } | |
| if (!$word_printed) { | |
| echo $i; | |
| } | |
| echo PHP_EOL; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment