Student Q and Student R

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

From Humanitarian-FOSS Project Development Site

  <meta http-equiv="Content-Type"
      content="text/html; charset=iso-8859-1">
  <title>12 Days Of Christmas</title>
<body bgcolor="#ffffff">
	/* This PHP program "sings" the song "The Twelve Days of
	 * Christmas" by printing each verse on a web page.
	 * Written by: Student Q and Student R

	/*$gifts is an associative array, storing the number of
	 * each day in the song and the corresponding gifts given
	 * on each day.
    	$gifts = array ("first"=>"A partridge in a pear tree",
			"second"=>"Two turtle doves",
			"third"=>"Three French hens",
			"forth"=>"Four calling birds",
			"fifth"=>"Five golden rings",
			"sixth"=>"Six geese a-laying",
			"seventh"=>"Seven swans a-swimming",
			"eigth"=>"Eight maids a-milking",
			"ninth"=>"Nine ladies dancing",
			"tenth"=>"Ten lords a-leaping",
			"eleventh"=>"Eleven pipers piping",
			"twelfth"=>"Twelve drummers drumming");
	/* function singVerse "sings" (prints) a verse of the song
	 * with the inputted number of day ($number) and gift given
	 * on that day ($gift).
	function singVerse($number, $gift)
		print "<p>On the $number day of Christmas,
                        <br>my true love gave to me";
	/*this foreach loops through the elements of the array and
	 * calls the singVerse function to print.
	foreach($gifts as $number => $gift)
		singVerse($number, $gift);
Personal tools