Student A

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">  12 Days Of Christmas  The 12 Days Of Christmas  $days = array(1=>"first", "second", "third", "fourth", "fifth",					"sixth", "seventh", "eighth", "ninth", "tenth",					"eleventh", "twelfth"); $numbers = array(1=>"a", "two", "three", "four", "five", "six",					"seven", "eight", "nine", "ten", "eleven", "twelve"); $gifts = array(1=>"partridge in a pear tree", "turtledoves", "French hens",					"calling birds", "golden rings", "geese", "swans", "maids",					"ladies", "lords", "pipers", "drummers"); $actions = array(6=>"a-laying", "a-swimming", "a-milking", "dancing",					"a-leaping", "piping", "drumming"); /* Construct lines of song and store in assoc. array like so: day => line e.g. "twelfth" => "twelve drummers drumming" */ $lines = array; foreach ($days as $index => $day) { $lines[$day] = $numbers[$index]. " " . $gifts[$index]; if (isset($actions[$index])) $lines[$day] .= " ". $actions[$index]; }			/* Start singing! */			for ($index = 1; $index <= 12; $index++) { echo("On the " . $days[$index] .					" day of Christmas my true love gave to me: "); echo(list_of_schwag($days[$index])); echo(" "); }

function list_of_schwag($day) { global $lines, $days; $list = ". "; // start from end & build backward foreach($lines as $index=>$line) { switch($index) { // get text between this line & next (if any): case $days[1]: $separator = ""; break; case $days[2]: $separator = ", and "; break; default: $separator = ", "; }					$list = $lines[$index]. $separator. $list; if ($index == $day) return $list; }			}