Student X

[article] [edit page] [discussion] [history]

From Humanitarian-FOSS Project Development Site

/* Twelve Days
*Program writes the song "The Twelve Days of Christmas"
*Student X

<title>The Twelve Days of Christmas</title>

$day=array("first"=>"A partridge in a pear tree",	//array that holds the verse information
              "second"=>"Two turtle doves",
              "third"=>"Three French hens",
              "fourth"=>"Four calling birds",
              "fifth"=>"Five golden rings",
              "sixth"=>"Six geese a-laying",
              "seventh"=>"Seven swans a-swimming",
              "eighth"=>"Eight maids a-milking",
              "ninth"=>"Nine ladies dancing",
              "tenth"=>"Ten lords a-leaping",
              "eleventh"=>"Eleven pipers piping",
              "twelfth"=>"Twelve drummers drumming");

function sing_days($verses)	//uses a foreach loop to print the day and verses
	$temp = array("","","","","","","","","","","","");
	foreach($verses as $daynum=>$gift){
		print("On the $daynum day of christmas<BR>");
		print("My true love gave to me<BR>");
		$temp[$i] = $gift;		// adds already used verses to a new array
		for ($x = $i-1;$x>=0;$x--){		//prints the verses before the current day
			if ($x==0){
				print("And " . strtolower($temp[$x]) . "<BR>");		


	sing_days($day);	//calls the function that writes the song
Personal tools