Added some examples. Returns NULL on failure. Will fail if one variable is

undefined.  See also max().


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@84374 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Philip Olson 2002-06-02 04:36:16 +00:00
parent 822cde2b99
commit 0833c63fa2

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.2 -->
<refentry id="function.min">
<refnamediv>
@ -25,7 +25,8 @@
<para>
In the first variant, you need at least two parameters
and <function>min</function> returns the lowest of these values.
You can compare an unlimited number of values.
You can compare an unlimited number of values. If one of the
variables is undefined, <function>min</function> will fail.
</para>
<para>
In the second variant, <function>min</function>
@ -36,7 +37,37 @@
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 <type>integer</type>s,
and an integer is returned.
and an integer is returned. Upon failure, <function>min</function>
returns <type>NULL</type> and an error of level <constant>E_WARNING</constant>
is generated.
</para>
<para>
<informalexample>
<programlisting>
<![CDATA[
<?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
?>
]]>
</programlisting>
</informalexample>
</para>
<para>
See also <function>max</function>.
</para>
</refsect1>
</refentry>