Ex No: 4 Write a program to Process Array
Aim: To perform array processing using php
Algorithm
Step1: Design a webpage to get five numbers.
Step2: On form submit check if array elements are set and not empty
   A) Get array value from POST method and assign large value as 0.
   B) Use foreach looping statement to cycle through array elements as x
     i) Check if x is greater than large value.
       a) If true then assign large value as x.
   c) Display the elements of the array using for loop.
   E) Display the largest value from large variable.

index.html


<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <title>Array Processing</title>
</head>
<body>
 <h3>Array Processing(Largest among 5 numbers)</h3>
  <form id="arrayform" name="arrayform" method="POST" action="ex4.php">
  <p>Enter Array Elements</p>
   <table>
    <tr><td><input type="text" name="arr[]"/></td></tr>
	<tr><td><input type="text" name="arr[]"/></td></tr>
	<tr><td><input type="text" name="arr[]"/></td></tr>
	<tr><td><input type="text" name="arr[]"/></td></tr>
	<tr><td><input type="text" name="arr[]"/></td></tr>
	<tr><td><input type="submit" value="Find Largest"/></td></tr>
  </table>
 </form>
</body>
</html>                     

ex4.php


<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <title>Array Processing</title>
</head>
<body>
 <?php
    
  #starting point of the php program
  if(isset($_POST["arr"]) && $_POST["arr"]!="")
  {
    $val = $_POST["arr"];
    $larg=0;
    foreach($val as $x)
    {
     if($x>$larg)
     {
      $larg = $x;
     }
    }
 ?> 
 <h3>Entered Array</h3>
 <p>
 <?php
    for($i=0;$i<5;$i++)
     echo $val[$i]." ";
 ?>
 </p>
 <p>Largest Values is <?php echo $larg; ?></p> 
 <?php
  }
 ?>
 </body>
</html>
                  
Result: Thus a webpage is designed using php to perform Array Processing.