Student I

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

From Humanitarian-FOSS Project Development Site

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html401/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Twelve Days of Christmas</title>
</head>
<body bgcolor="#ffffff">

<?php

/**
 * Student I 
 * CPSC-225 Assignment #1
 * 2/5/07
 */


/**
 * --- Function sing
 * Takes a "recursive" song (such as the 12 Days of Christmas) stored in an array and  
 * prints it.
 * --- param:
 * array $song = array containing the song
 */

function sing($song)
{
	$verse = "<br>";
	foreach($song as $day => $line)
	{
		print "On the " . $day . " day of Christmas my true love gave to me: ";
		$verse = "<br>" . $line . " " . $verse;
		print $verse;
	}
}

/**
 * --- array $twelve_days
 * stores the lyrics to the twelve days of Christmas
 */

$twelve_days = array("first"=>"A Partridge in a Pear Tree. <br>", "second"=>"Two turtle 
doves,  and", "third"=>"Three French hens,", "fourth"=>"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,");


sing($twelve_days);

?>

</body></html>
Personal tools