log1p
<<<
max min
>>>

7.50 Mathématiques
7 Index des fonctions
 Manuel PHP

. Introduction
. Pré-requis
. Installation
. Configuration à l'exécution
. Types de ressources
. Constantes prédefinies
. abs
. acos
. acosh
. asin
. asinh
. atan
. atan2
. atanh
. base_convert
. bindec
. ceil
. cos
. cosh
. decbin
. dechex
. decoct
. deg2rad
. exp
. expm1
. floor
. fmod
. getrandmax
. hexdec
. hypot
. is_finite
. is_infinite
. is_nan
. lcg_value
. log
. log10
. log1p
->max
. min
. mt_getrandmax
. mt_rand
. mt_srand
. octdec
. pi
. pow
. rad2deg
. rand
. round
. sin
. sinh
. sqrt
. srand
. tan
. tanh

7.50.38 max()La plus grande valeur

[ Exemples avec max ]   PHP 3, PHP 4

mixed  max ( number   arg1 , number   arg2 , number   ... ) mixed  max ( array   numbers , array   ... )

max retourne 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 nombre à virgule flottante ( float ), max requiert au moins deux paramètres, et retournera alors le plus grand d'entre eux. Le nombre d'arguments est alors illimité.

Si au moins une valeur est un nombre à virgule flottante, elles seront toutes traitées comme des nombres à virgule flottante, et un nombre à virgule flottante sera retourné. Si aucune valeur n'est un nombre à virgule flottante, elles seront traitées comme des entiers, et un entier sera retourné.

Exemple d'utilisation de max

<?php
echo max(1, 3, 5, 6, 7);  // 7
echo max(array(2, 4, 5)); // 5

echo max(0, 'bonjour');     // 0
echo max('bonjour', 0);     // bonjour
echo max(-1, 'bonjour');    // bonjour

// Avec plusieurs tableaux, min() fait les comparaisons de gauche à droite
// dans notre exemple : 2 == 2, mais 4 < 5
$val = max(array(2, 4, 8), array(2, 5, 7)); // array(2, 5, 7)

// Si un mélange de tableau et de scalaires sont fournis,
// le tableau est toujours retourné, car il est considéré comme le plus grand
$val = max('string', array(2, 5, 7), 42);   // array(2, 5, 7)
?>

Voir aussi min et count .

<< max >>
log1p Mathématiques min