Skip to content

min ​

php
mixed min ( array $tablica )

mixed min ( mixed $wartosc1 , mixed $wartosc1 [, mixed $... ] ) Returns the smallest of the supplied values. If the only argument is an array, returns its smallest element. If multiple arguments are supplied, returns the smallest argument.

For strings, whether passed as arguments or in an array, character ASCII codes are compared. When two or more arrays are passed as arguments, the array with the fewest elements is selected.

Example 1:

php
$liczba1 = 30;
$liczba2 = 20;
$liczba3 = 19;
print("The smallest number in the set: {".$liczba1.",".$liczba2.",".$liczba3."}");
print(" is ".min($liczba1,$liczba2,$liczba3));

Result:

The smallest number in the set: {30,20,19} is 19

Example 2:

php
$zbior = array(33,17,47,33);
print("The smallest number in the set: \n");
print_r($zbior);
print("is: ".min($zbior));

Result:

The smallest number in the set:
Array
(
    [0] => 33
    [1] => 17
    [2] => 47
    [3] => 33
)
is: 17