★ wanayoo — archive 1999 http://www.php.net/manual/function.min.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Math.
Quick Reference
German version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
Math.
* abs
* acos
* asin
* atan
* atan2
* base_convert
* bindec
* ceil
* cos
* decbin
* dechex
* decoct
* deg2rad
* exp
* floor
* getrandmax
* hexdec
* log
* log10
* max
* min
* mt_rand
* mt_srand
* mt_getrandmax
* number_format
* octdec
* pi
* pow
* rad2deg
* rand
* round
* sin
* sqrt
* srand
* tan
Manual: min
View the source code for this pageSearch the site



Previous page
 max
 Updated
Sat, 12 Aug 2000
mt_rand 
Next page


min

(PHP3 , PHP4 )

min -- Find lowest value

Description

mixed min (mixed arg1, mixed arg2, mixed argn)

Min() returns the numerically lowest of the parameter values.

If the first parameter is an array, min() returns the lowest value in that array. If the first parameter is an integer, string or double, you need at least two parameters and min() returns the lowest of these values. You can compare an unlimited number of values.

If one or more of the values is a double, all the values will be treated as doubles, and a double is returned. If none of the values is a double, all of them will be treated as integers, and an integer is returned.


User Contributed Notes: min


nickl@mycomputer.com
01-Jul-1999 06:54
this fails if you attempt to pass an
expression such as min($foo-$bar, $gumby);



thenoog@hotmail.com
19-Dec-1999 10:42
I have had cases where min() doesn't work at all. I encourage you to make one by hand just to be sure.

Here is a sample of the problem:

<pre>
$last = $rowcount-1;
echo "$last, $offset, ".min($last,$offset);
</pre>

if $rowcount=4 and $offset=0 the min() returns 4! Don't know why. Don't care.

Here is a simple replacement:

<pre>
Function myMin( $a, $b )
{
if( $a < $b ) return $a;
return $b;
}
</pre>




ah@artemis.dk
04-Mar-2000 01:11
Make sure that your parameters have the same type.

Example:
<pre>
list($max)= mysql_fetch_array(....
/* $max is now 6 */
$min= 50;
$fisk= min($min,$max);
</pre>
$fisk is now 50, because $max is a string and '50' < '6'.
Simply use min($min,$max+0)instead.



billgr@sunoptics.caltech.edu
23-Mar-2000 03:05
This last note works for me: I just add "+0" to min args. Then expressions inside arguments work as well.

As a guess, I'd say this would be harder to fix than it might look, due to loose typing in PHP and the way it builds expressions internally.



 About Notes


Previous page
 max
 Updated
Sat, 12 Aug 2000
mt_rand 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.