Skip to content

Instantly share code, notes, and snippets.

@ctrl-freak
Created August 3, 2017 10:15
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 ctrl-freak/b4829f2860fc1614452404eb509a3bee to your computer and use it in GitHub Desktop.
Save ctrl-freak/b4829f2860fc1614452404eb509a3bee to your computer and use it in GitHub Desktop.
FizzBuzz.php
<?php
$check = array(
3 => 'Fizz',
5 => 'Buzz',
);
for ($i = 1; $i <= 100; $i++) {
$output = '';
foreach ($check as $key=>$value) {
if (!($i % $key)) {
$output .= $value;
}
}
!empty($output) ?: $output = $i;
echo $output."\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment