VB icon

High and Low Number Checker in PHP

Email
Submitted on: 11/29/2015 12:57:13 PM
By: Jake R. Pomperada  
Level: Beginner
User Rating: Unrated
Compatibility: PHP 3.0, PHP 4.0, PHP 5.0
Views: 2155
author picture
 
     This sample program that I wrote in PHP will check for the highest and lowest number from the five number given by the user using one dimensional array in PHP. Take note I did not use any built in function in PHP like Max and Min function to determine the highest and lowest number. I hope you will find my work useful in learning how to program in PHP. If you have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: High and Low Number Checker in PHP
// Description:This sample program that I wrote in PHP will check for the highest and lowest number from the five number given by the user using one dimensional array in PHP. Take note I did not use any built in function in PHP like Max and Min function to determine the highest and lowest number. I hope you will find my work useful in learning how to program in PHP.
If you have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com. 
My mobile number here in the Philippines is 09173084360.
// By: Jake R. Pomperada
//**************************************

<?php
error_reporting(0);
$a = $_POST["numbers"][0];
$b = $_POST["numbers"][1];
$c = $_POST["numbers"][2];
$d = $_POST["numbers"][3];
$e = $_POST["numbers"][4];
if ($_POST['send']) 
 {
$list=array($a,$b,$c,$d,$e);
$highest_number=0;
$lowest_number=0;
$high=0;
$low=0;
// checking for highest number
 $highest_number = $list[0];
foreach($list as $high)
{
 if ($highest_number < $high)
 {
$highest_number = $high;
 } 
}
 
// checking for lowest number
$lowest_number = $list[0];
 foreach($list as $low)
 {
if ($lowest_number > $low)
{
 $lowest_number = $low;
} 
 }
 }
 
 if ($_POST['clear'])
{
$a=""; $b=""; $c=""; $d=""; $e="";
$highest_number="";
$lowest_number=""; 
 }
?>
<html>
 <style>
 body {
 font-family:arial;
 font-size:12;
 }
</style>
<title> Highest and Lowest Number Checker</title>
<form action = "" method = "POST">
<body>
<h3> Highest and Lowest Number Checker </h3>
<table border = "0">
<tr>
<td> 1st Value </td>
<td> <input type = "text" name ="numbers[]" value = "<?php echo $a;?>" size="5" autofocus required>
</tr>
<tr>
<td> 2nd Value </td>
<td> <input type = "text" name ="numbers[]" value = "<?php echo $b;?>" size="5" required>
</tr>
<tr>
<td> 3rd Value </td>
<td> <input type = "text" name ="numbers[]" value = "<?php echo $c;?>" size="5" required>
</tr>
<tr>
<td> 4th Value </td>
<td> <input type = "text" name ="numbers[]" value = "<?php echo $d;?>" size="5" required >
</tr>
<tr>
<td> 5th Value </td>
<td> <input type = "text" name ="numbers[]" value = "<?php echo $e;?>" size="5" required>
</tr>
<tr>
<td>  </td>
</tr>
<tr>
<tr>
<td> <b> Highest Number </b> </td>
<td> <input type = "text" value = "<?php echo $highest_number;?>" size="5" readonly>
</tr>
<tr>
<td>  </td>
</tr>
<tr>
<td> <b>Lowest Number </b> </td>
<td> <input type = "text" value = "<?php echo $lowest_number;?>" size="5" readonly>
</tr>
<tr>
<td>  </td>
</tr>
<tr>
<td colspan = 3>
<input type = "submit" name="send" value = "OK" title="Click here to check highest and lowest number.">
  
<input type = "submit" name="clear" value = "Clear" title="Click here to clear text boxes.">
</td>
</tr>
</table>
</form>
 </body>
 </html>


Other 46 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.