05-14-2009, 02:39 PM
|
#19 (permalink)
|
|
The Contributor
Join Date: Mar 2009
Location: US
Posts: 76
Thanks: 0
|
Quote:
Originally Posted by ioan1k
Even Shorter...... and gives the correct ending :)
PHP Code:
for ($i = 1; $i <= 99; $i++) { $first = ($i != 99) ? 99 - ($i - 1).' bottles of beer ' : ' 1 bottle of beer '; $last = ($i == 99) ? ' no more bottles ' : (($i == 98) ? '1 bottle ' : 99 - $i.' bottles '); echo sprintf('%s on the wall %s <br /> Take one down pass it around of %s beer on the wall <br />', $first, $first, $last); }
|
:)
PHP Code:
echo 'Go to the store and buy some more, 99 bottles of beer on the wall.';
|
|
|
|