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

PHP Home Page

Manual Table of Contents
Up to Maths
Quick Reference
English version of this pageGerman version of this pageJapanese version of this pageItalian version of this pageHungarian version of this page
Maths
* Abs
* Acos
* Asin
* Atan
* Atan2
* base_convert
* BinDec
* Ceil
* Cos
* DecBin
* DecHex
* DecOct
* Exp
* Floor
* getrandmax
* HexDec
* Log
* Log10
* max
* min
* mt_rand
* mt_srand
* mt_getrandmax
* number_format
* OctDec
* pi
* pow
* rand
* round
* Sin
* Sqrt
* srand
* Tan
Manual: max
View the source code for this pageSearch the site



Previous page
 Log10
 Updated
Sun, 06 Aug 2000
min 
Next page


max

(PHP3 , PHP4 )

max -- La plus grande valeur.

Description

mixed max (mixed arg1, mixed arg2, mixed argn)

max() retourne la la plus grande valeur numérique parmi les valeurs passées en paramètre.

Si le premier paramètre est un tableau, max() retourne la plus grande valeur de ce tableau. Si le premier paramètre est un entier, une chaîne ou un double, max() requiert au moins deux paramètres, et retournera alors le plus grand d'entre eux. Le nombre d'argument est alors illimité.

Si au moins une valeur est de type double, elle seront toutes traitées comme des doubles, et un double sera retourné. Si aucune valeur n'est de type double, elles seront traitées comme des entiers, et un entier sera retourné.


User Contributed Notes: max


craigsrubbish@hotmail.com
03-Aug-2000 04:18
I came across a problem that the description above doesn't seem to make clear.

In my implementation of php3 and mysql, if you have 3 database values such as (6,8,50), the max will come out as "8", as it seems to have trouble with integers that aren't the same length.

in my case this was solved by making the database field ZEROFILL'ed, so the values compared came out as (0006,0008,0050).

But I'm sure someone has a smarter way!



t.hochgreve@pm-konzept.de
07-Aug-2000 08:16
to craigsrubbish: sure fetching values from a mysql database returns strings, whether a field is numeric or not. When sending the fetched values to max() they will be compared as if they were strings: max ('2','8','50'). To compare numbers, cast the values to integer: max((int)'2', (int)'8', (int)'50).


 About Notes


Previous page
 Log10
 Updated
Sun, 06 Aug 2000
min 
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.