Skip to content

Instantly share code, notes, and snippets.

@kezzyhko
Last active November 10, 2020 21:27
Show Gist options
  • Select an option

  • Save kezzyhko/4761479fc97c9f5e3fce708c54e870bc to your computer and use it in GitHub Desktop.

Select an option

Save kezzyhko/4761479fc97c9f5e3fce708c54e870bc to your computer and use it in GitHub Desktop.
<?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