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

PHP Home Page

Manual Table of Contents
Up to Mat.
Quick Reference
English version of this pageGerman version of this pageJapanese version of this pageFrench version of this pageHungarian version of this page
Mat.
* 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: 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 -- trova il valore massimo

Descrizione

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

max() restituisce il numericamente più grande dei valori dati come parametro.

Se il primo parametro è un array, max() restituisce il massimo dei valori di tale array. Se il primo parametro è un integer, string o double, si ha bisogno almeno di due parametri e max() restituisce il maggiore di tali valori. Si può confrontare un numero illimitato di valori.

Se uno o più valori sono double, tutti i valori saranno considerati come double, e verrà restituito un double. Se nessuno dei valori è double, tutti verranno considerati come integer, e verrà restituito un integer.


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.