View Single Post
Old 05-14-2009, 02:39 PM   #19 (permalink)
ioan1k
The Contributor
 
ioan1k's Avatar
 
Join Date: Mar 2009
Location: US
Posts: 76
Thanks: 0
ioan1k is on a distinguished road
Default

Quote:
Originally Posted by ioan1k View Post
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.'
__________________
My Portfolio - Work - Need freelance Work?
I've been developing 5 years now, and I learn something new everyday
ioan1k is offline  
Reply With Quote