min
Description
Syntax
min ( array $values ) : mixed
min ( mixed $value1 [, mixed $... ] ) : mixed
Parameters
values
An array containing the values.
value1
Any comparable value.
...
Any comparable value.
Return
min() returns the parameter value considered "lowest" according to standard comparisons. If multiple values of different types evaluate as equal (e.g. 0 and 'abc') the first provided to the function will be returned. If an empty array is passed, then FALSE will be returned and an E_WARNING error will be emitted.
Examples
1 · values
<? $values = array(1, 2, 3); $return = min($values); echo $return;
1
2 · value1 ...
<? $value1 = 1; $value2 = 2; $value3 = 3; $return = min($value1, $value2, $value3); echo $return;
1
3 · First
<? $value1 = 0; $value2 = false; $value3 = null; $return = min($value1, $value2, $value3); var_dump($return);
int(0)
4 · First
<? $value1 = 1; $value2 = true; $return = min($value1, $value2); var_dump($return);
int(1)
5 · First
<? $value1 = 0; $value2 = "abc"; $return = min($value1, $value2); echo $return;
0
6 · Length
<? $value1 = array(1, 2, 3); $value2 = array(3, 2); $return = min($value1, $value2); print_r($return);
Array ( [0] => 3 [1] => 2 )
7 · Left to Right
<? $value1 = array(1, 2, 3); $value2 = array(3, 2, 1); $return = min($value1, $value2); print_r($return);
Array ( [0] => 1 [1] => 2 [2] => 3 )