99 Bottles of Beer by lfo

<?php

$left = 99;
for ($i=99; $i>0; --$i) {

    $txt = $i." bottle";

    if ($i>1) $txt .= "s";
    $txt .= " of beer on the wall, ".$i." bottle";

    if ($i>1) $txt .= "s";
    $txt .= " of beer.\n";

    $left--;
    if ($left == 0) $left = "no more";
    $txt .= "Take one down and pass it around, ".$left." bottle";

    if ($left>1 || $left=="no more") $txt .= "s";
    $txt .= " of beer on the wall";
    if ($left!=0) $txt .= ".";
    $txt .= "\n";

    print $txt;

}

print "No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.\n";

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

To protect the system from spam, please input your favorite sport (hint: I believe its name must start with 'g', case insensitive)

download

return to the top page