Professional Documents
Culture Documents
<html>
<head>
<title>Title here!</title>
</head>
<body>
<?php
$student= array("Muhammad", "Idris", "Ahmad", "Zakaria",
"Ayub", "Muhammad", "Zakaria", "Yunus", "Yusof");
<html>
<head>
<title>Title here!</title>
</head>
<body>
<form name="f1" method="POST" action="compareProcess.php">
<?php
for($i=1; $i<=10; $i++)
{
echo "<p>Top 10 in Area $i: <input type='text' name='area[$i]'
size='10'></p>";
Page 1 of 3
}
?>
<input type="submit" name="hantar" value="Different">
<input type="submit" name="hantar" value="Intersection">
<input type="reset" name="reset" value="Cancel">
</form>
</body>
</html>
Step 2 : Write the following php to compare two arrays (area and population) and save as
compareProcess.php
<html>
<head>
<title>Top 10 Area and Population</title>
</head>
<body>
<?php
//get data from form
$areaArray= $_POST['area'];
$populationArray= $_POST['population'];
$buttonSubmit = $_POST[‘hantar’];
switch ($buttonSubmit)
{
case "Different":
$ResultArray = array_diff($areaArray, $arrayPopulation);
$ResultArray = array_value($ResultArray);
echo “<br /> The following of the most populous countries are not
also the largest in area: <br />”;
asort($ResultArray);
Page 2 of 3
foreach($ResultArray as $count => $result)
echo "Country [$count] : $result <br>";
break;
case "Intersection":
$ResultArray = array_intersec($areaArray, $arrayPopulation);
$ResultArray = array_value($ResultArray);
echo “<br /> The following of the most populous countries are
also among the largest in area: <br />”;
asort($ResultArray);
foreach($ResultArray as $count => $result)
echo "Country [$count] : $result <br>";
break;
}
?>
</body>
</html>
Area : Russia, China, Canada, United States, Brazil, Australia, India, Argentina, Kazakhstan, Algeria
Population : China, India, United States, Indonesia, Brazil, Pakistan, Bangladesh, Rusia, igeria, Japan
Step 4: Click on Different Button. What are output? Explain your answer. Submit your answer on kelip
assignment 2 Step 4.
Step 5: Using the same input, click on Intersection Button. What are output? Explain your answer.
Submit your answer on kelip assignment 2 Step 5.
Write a program to input daily temperature for 30 days and one button (sort and Count). After user click
sorting and count buttons, it will invoke the tempProcess.php to display daily temperature in sorted
value and count the number of hot days, pleasant days as well as cold days in a month according to the
table below:
Page 3 of 3