Skip to content

Instantly share code, notes, and snippets.

@jrmadsen67
Last active May 1, 2017 21:32
Show Gist options
  • Save jrmadsen67/5815505 to your computer and use it in GitHub Desktop.
Save jrmadsen67/5815505 to your computer and use it in GitHub Desktop.
Next time someone asks you to take a FizzBuzz Test...
$biggest =100;
$all_numbers = range(0,$biggest);
$threes = array_fill_keys(range(3, $biggest, 3), 'Fizz');
$fives = array_fill_keys(range(5, $biggest, 5), 'Buzz');
$fifteens = array_fill_keys(range(15, $biggest, 15), 'FizzBuzz');
$all_numbers = array_replace($all_numbers, $threes, $fives, $fifteens);
var_dump($all_numbers);
@jrmadsen67
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment