min

Find lowest value

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);

?>
<!doctype html>
<html>
<head>
    <title>PHP</title>
    <style>
        a
        {
            background-color: rgba(255,0,255,0.1);
            color: purple;
        }
        a:hover
        {
            background-color: rgba(0,0,0,0.1);
            color: black;
        }
    </style>
</head>
<body>
    <a href="/php/">PHP</a>
    <script>
        function myfunction()
        {
            const myelement = document.querySelector("a");
            const mystyle = myelement.style;
            mystyle.position = "absolute";
            mystyle.left = Math.random() * (window.innerWidth - myelement.offsetWidth) + "px";
            mystyle.top = Math.random() * (window.innerHeight - myelement.offsetHeight) + "px";
        }
        document.querySelector("a").addEventListener("mouseout", myfunction);
    </script>
</body>
</html>

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
)

abs

acos

acosh

asin

asinh

atan

atan2

atanh

base_convert

bindec

ceil

cos

cosh

decbin

dechex

decoct

deg2rad

exp

expm1

fdiv

floor

fmod

hexdec

hypot

intdiv

is_finite

is_infinite

is_nan

log

log10

log1p

max

octdec

pi

pow

rad2deg

round

sin

sinh

sqrt

tan

tanh

PHP

Home Menu