Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Fizzbuzz implementation in PHP with minimal codes
// PHP fizzbuzz implementation by Jitendra Adhikari
// see:
// 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)));
Copy link

Xeoncross commented Dec 9, 2013

Rather than ==0 just move it a little and use ! conditional checks.

Copy link

adhocore commented Dec 10, 2013

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!

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