99 Bottles of Beer Song (PHP5)

Found this while hunting for a file. It’s an old submission to the 99 bottles of beer website. I don’t think they ever posted it, but it was just a fun way to kill time.

Source

#!/usr/local/php5/bin/php
<?
foreach(range((is_numeric($argv[1]) ? $argv[1] : 99),1,1) as $number)
	printf(
		"%1\\$d bottle%3\\$s of beer on the wall,
		%1\\$d bottle%3\\$s of beer.\\nTake one down, pass it around,
		%2\\$d bottle%4\\$s of beer on the wall.\\n\\n",
			$number,
			$number - 1,
			 ($number == 1 ? '' : 's'),
			($number - 1 == 1 ? '' : 's')
	);
echo "*BUUURP!*\\n";
?>

Usage
Nothing fancy. Just run change the shebang and chmod +x [filename];./[filename] [#]

Was just curious to see if i could fit it all on 1 line. I’m sure it can be shortened, and if I get bored it might :) , but for right now, it is what it is.




Comments

No comments yet.

Add Yours

  • Author Avatar

    YOU


Comment Arrow



About Author

Rob Hurring

Ruby, Rails, PHP, bash... oh my!