jonsjava Posted July 8, 2008 Share Posted July 8, 2008 Improve the script (either by making it more complex, or more simple): <?php $count = 99; while ($count > 0){ print "<pre>".$count." bottles of beer on the wall, ".$count." bottles of beer.\n Take one down and pass it around, ".--$count." bottles of beer on the wall.\n\n"; } print "<pre>No more bottles of beer on the wall, no more bottles of beer.\n Go to the store and buy some more, 99 bottles of beer on the wall."; ?> Quote Link to comment Share on other sites More sharing options...
ratcateme Posted July 8, 2008 Share Posted July 8, 2008 here <pre> <?php $count = 99; while ($count > 0) { switch($count){ case 1: $bottle_1 = "bottle"; $bottle_2 = "bottles"; $one_it = "it"; break; default : $bottle_1 = "bottles"; $bottle_2 = "bottles"; $one_it = "one"; break; case 2: $bottle_2 = "bottle"; } print "{$count} {$bottle_1} of beer on the wall, {$count} {$bottle_1} of beer. Take {$one_it} down and pass it around, " . --$count . " {$bottle_2} of beer on the wall.\n\n"; } print "<pre>No more bottles of beer on the wall, no more bottles of beer.\n Go to the store and buy some more, 99 bottles of beer on the wall."; ?> </pre> Scott. Quote Link to comment Share on other sites More sharing options...
ratcateme Posted July 8, 2008 Share Posted July 8, 2008 made it shorter again switch($count){ default : $bottle_1 = "bottles"; $bottle_2 = "bottles"; $one_it = "one"; break; case 1: $bottle_1 = "bottle"; $one_it = "it"; break; case 2: $bottle_2 = "bottle"; } Scott. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.