min() returns the numerically
lowest of the parameter values.
In the first variant, you need at least two parameters
and min() returns the lowest of these
values. You can compare an unlimited number of values. If one
of the variables is undefined, min()
will fail.
In the second variant, min()
returns the lowest value in
numbers.
If one or more of the values is a float,
all the values will be treated as floats, and a float is
returned. If none of the values is a float, all of them will
be treated as integers, and an integer is returned. Upon
failure, min() returns NULL and an
error of level E_WARNING is
generated.
?php $a = 4; $b = 9; $c = 3; $arr = array(99, 34, 11); // You may want to implement your own error checking in // case of failure (a variable may not be set) if (!$min_value = @min($a, $b, $c)) { echo "Could not get min value, please try again."; } else { echo "min value is $min_value"; } print min($arr); // 11 ? |
See also max().