<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="main.css"/>
</head>
<body>
<div>
<?php
// define cheeses
$cheese[0]['name']='Vachrin Mont d\'Or';
$cheese[0]['origin']='Jura';
$cheese[1]['name']='Camenbert';
$cheese[1]['origin']='Normandy';
$cheese[2]['name']='Pont l\'Eveque';
$cheese[2]['origin']='Normandy';
$cheese[3]['name']='Crotin de Frauxbourcq';
$cheese[3]['origin']='Normandy';
$cheese[4]['name']='Conquoiotte';
$cheese[4]['origin']='Franche Comte';
$cheese[5]['name']='Comte';
$cheese[5]['origin']='Franche Comte';
// first loop. For each cheese, concatenate
// a string of origins
foreach ($cheese as $fromage) {
$origin=$fromage['origin'];
$cheeses_produced[$origin][]=$fromage['name'];
}
// loop over the regions to get the print
foreach ($cheeses_produced as $region => $fromages) {
// count the number of cheeses
$count_cheeses=count($cheeses_produced[$region]);
print "$region produces ";
// first case: only one cheese
if($count_cheeses==1) {
print $cheeses_produced[$region][0];
}
else {
print "$count_cheeses cheeses: ";
// use an enumerator to count through
// the cheesse, just to make sure with
// get the word "and" with the last cheese
$enumerator=0;
while($enumerator < $count_cheeses-1) {
print $cheeses_produced[$region][$enumerator];
print ", ";
$enumerator++;
}
// last cheese.
print "and ";
print $cheeses_produced[$region][$count_cheeses-1];
}
// and now the dot at the end of the sentence
print ".<br/>";
}
?>
</div>
<p id="validator">
<a href="http://validator.w3.org/check?uri=referer"><img
style="border: 0pt"
src="http://dlib.info/valid-xhtml10.png"
alt="Valid XHTML 1.0!" height="31" width="88" /></a>
</p>
</body>
</html>