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."; ?> Link to comment https://forums.phpfreaks.com/topic/113673-just-for-fun/ 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. Link to comment https://forums.phpfreaks.com/topic/113673-just-for-fun/#findComment-584176 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. Link to comment https://forums.phpfreaks.com/topic/113673-just-for-fun/#findComment-584178 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.