Created
May 19, 2016 13:47
-
-
Save davidstanley01/2e1d3fc87c66caa60db0349ef26a9664 to your computer and use it in GitHub Desktop.
Revisions
-
davidstanley01 created this gist
May 19, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ <?php function getFizzBuzz($max) { for ($i = 0; $i < $max; $i++) { $string = null; $string = ($i % 15) === 0 && is_null($string) ? 'FizzBuzz' : null; $string = ($i % 3) === 0 && is_null($string) ? 'Fizz' : $string; $string = ($i % 5) === 0 && is_null($string) ? 'Buzz' : $string; yield $string; } } $max = 1000; echo '<ul style="list-style-type:none;">'; foreach (getFizzBuzz($max) as $key => $value) { echo echo sprintf('<li>%s - %s</li>', $key, $value); } echo '</ul>';