Created
December 8, 2013 16:27
-
-
Save adhocore/7859738 to your computer and use it in GitHub Desktop.
Fizzbuzz implementation in PHP with minimal codes
This file contains 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 characters
<?php | |
// PHP fizzbuzz implementation by Jitendra Adhikari | |
// see: http://content.codersdojo.org/code-kata-catalogue/fizz-buzz/ | |
// | |
// if you have shorter/smarter ways out, please fork or comment... | |
echo implode('<br/>', array_map(function($d){ | |
return ($d%15==0)?'fizzbuzz':($d%5==0?'buzz':($d%3==0?'fizz':$d)); | |
}, range(1,100))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yup, thought of that before; btw, it just makes code short in span not in terms of byte, because for removing
==0
from$d%15==0
, we again need some 3 extra chars!()
as such!($d%15)
, so i dint really wrote that way for sake of readability and straight forward code!