/
bottlesOfBeer_song.php
35 lines (32 loc) · 990 Bytes
/
bottlesOfBeer_song.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
// Loop through the lyrics, counting down one at a time
// say bottle (singular) when there is only 1 bottle
// say No more bottles when there are 0 bottles
for($b = 3; $b >= 0; $b--){
if($b == 1){
echo `say $b bottle of beer on the wall, `;
echo `say $b bottle of beer. `;
echo `say Take one down, pass it around, `;
echo `say No more bottles of beer on the wall. `;
usleep(500000);
} elseif($b == 0){
echo `say No more bottles of beer on the wall, `;
echo `say No more bottles of beer. `;
echo `say Go to the store and buy some more, `;
echo `say 99 bottles of beer on the wall. `;
usleep(500000);
} else {
echo `say $b bottles of beer on the wall, `;
echo `say $b bottles of beer. `;
echo `say Take one down, pass it around, `;
if ($b == 2){
echo `say 1 bottle of beer on the wall. `;
usleep(500000);
} else {
$c = $b - 1;
echo $c. `say $c bottles of beer on the wall. `;
usleep(500000);
}
}
}
?>