Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Last active December 10, 2015 05:48
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 ziadoz/4390632 to your computer and use it in GitHub Desktop.
Save ziadoz/4390632 to your computer and use it in GitHub Desktop.
The Fizz Buzz problem solved in PHP.
<?php
// http://content.codersdojo.org/code-kata-catalogue/fizz-buzz/
foreach (range(1, 100) as $i) {
$x = '';
$x .= ($i % 3 === 0 ? 'Fizz' : '');
$x .= ($i % 5 === 0 ? 'Buzz' : '');
echo $i . ' ' . (empty($x) ? $i : $x) . "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment