★ wanayoo — archive 1999 http://www.php.net/manual/function.max.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: max
View the source code for this pageSearch the site



Previous page
 log10
 Updated
Sat, 12 Aug 2000
min 
Next page


max

(PHP3 , PHP4 )

max -- Find highest value

Description

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

max() returns the numerically highest of the parameter values.

If the first parameter is an array, max() returns the highest value in that array. If the first parameter is an integer, string or double, you need at least two parameters and max() returns the biggest 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: 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
Sat, 12 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.