Skip to content

Instantly share code, notes, and snippets.

@wingchi
Created October 2, 2015 16:31
Show Gist options
  • Select an option

  • Save wingchi/c6900db2b6114d26ec1b to your computer and use it in GitHub Desktop.

Select an option

Save wingchi/c6900db2b6114d26ec1b to your computer and use it in GitHub Desktop.
$oneString = array("", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine");
$tenString = array("", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety", "one hundred");
$teenString = array("", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen");
for ($count = 100; $count > 0; --$count) {
$next = $count - 1;
$count_text = (!($count>10 && $count<20) ? $tenString[$count/10] . (($count%10 != 0 && $count>9) ? " " : "") . $oneString[$count%10] : $teenString[$count-10]);
$next_text = (!($next>10 && $next<20) ? $tenString[$next/10] . (($next%10 != 0 && $next > 9) ? " " : "") . $oneString[$next%10] : $teenString[$next-10]);
print (ucFirst($count_text). " bottles of beer on the wall, " . $count_text . " bottles of beer! Take one down, and pass it around; " . $next_text . " bottles of beer on the wall!
");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment