Skip to content

Instantly share code, notes, and snippets.

@mattonomics
Created March 6, 2012 23:51
Show Gist options
  • Save mattonomics/1989872 to your computer and use it in GitHub Desktop.
Save mattonomics/1989872 to your computer and use it in GitHub Desktop.
Dummy Test
<?php
/*
Count from 1-100. If the number is divisible by 3 & 5, output "FizzBuzz".
If divisible by 3 but not 5, output "Fizz".
If divisible by 5 but not 3, output "Buzz".
Otherwise output the number.
*/
function loop_it() {
$out = '';
for($i = 1; $i <= 100; $i++)
$out .= is_int($i / 3) ? (is_int($i / 5) ? "FizzBuzz " : "Fizz ") : (is_int($i / 5) ? "Buzz " : "$i ");
return $out;
}
echo loop_it();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment