SpitFirez
SpitFirez

Reputation: 9

Php least number

can any one help me about how to find the least number of five inputs like 1,2,3,4,5 where the least is 1...

and find the 2nd least number where it is 2 then 3rd least number where it is 3 and 4th least numb where it is 4 and the largest number where it is 5..

<input type ="text" name ="num1">
<input type ="text" name ="num2">
<input type ="text" name ="num3">
<input type ="text" name ="num4">

<input type ="text" name ="answer">

Upvotes: 0

Views: 106

Answers (2)

li9ht
li9ht

Reputation: 464

$values = array($_POST["num1"],$_POST["num2"],$_POST["num3"],$_POST["num4"]);
sort($values);
var_dump($values);

Upvotes: 0

alex
alex

Reputation: 490471

You would sort() the numbers and then echo them back into the value attribute of your answer element.

Upvotes: 4

Related Questions