Array
Array.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Array</title>
</head>
<body>
<p>My eight Web 2 students have just taken their final exam.
It was very difficult so I decided to buy my 'A' students a new car.
Here are their scores: </p>
Student1: 89.4<br>
Student2: 89<br>
Student3: 90<br>
Student4: 91<br>
Student5: 89.3<br>
Student6: 92<br>
Student7: 99<br>
Student8 :99.9<br>
<p>Let's use PHP to display the great news.
We will use an array to store the values.</p>
<?php
$grades[0]= 89.4;
$grades[1]= 89;
$grades[2]= 90;
$grades[3]= 91;
$grades[4]= 89.3;
$grades[5]= 92;
$grades[6]= 99;
$grades[7]= 99.9;
echo "<p>";
echo "There are ".count($grades)." grades in the array.";
echo "</p>";
for ($counter=0; $counter < count($grades) ; $counter=$counter+1)
{
if ($grades[$counter] >89.5)
{
print("A new car for student ".($counter+1)."!<br>");
}
}
?>
</body>
</html>