Google News
logo
PHP Program to Find the lowest and highest value in a list of arguments
In PHP, you can find the lowest and highest value in a list of arguments using the `min()` and `max()` functions, respectively. Here's an example:
Program :
<?php
$values = array(3, 7, 1, 9, 2);
$lowest = min($values);
$highest = max($values);

echo "The lowest value is: $lowest\n";
echo "The highest value is: $highest\n";
?>
Output :
The lowest value is: 1
The highest value is: 9
In this example, an array named `$values` is defined with a list of values. The `min()` function is called with `$values` as an argument to find the lowest value in the array, and the `max()` function is called with `$values` as an argument to find the highest value in the array.

The values of `$lowest` and `$highest` are then output using `echo`.

Note that the `min()` and `max()` functions can also be called with multiple arguments instead of an array, like this :
Program :
<?php
$lowest = min(3, 7, 1, 9, 2);
$highest = max(3, 7, 1, 9, 2);

echo "The lowest value is: $lowest\n";
echo "The highest value is: $highest\n";
?>
Output :
The lowest value is: 1
The highest value is: 9
This will produce the same output as the previous example.