(PHP 4, PHP 5, PHP 7, PHP 8)
max — 找出最大值
如果僅有一個參數(shù)且為數(shù)組,max() 返回該數(shù)組中最大的值。如果第一個參數(shù)是整數(shù)、字符串或浮點數(shù),則至少需要兩個參數(shù)而 max() 會返回這些值中最大的一個??梢员容^無限多個值。
注意:
PHP 會將非數(shù)值的 string 當成
0,但如果這個正是最大的數(shù)值則仍然會返回一個字符串。如果多個參數(shù)都求值為0且是最大值,max() 會返回其中數(shù)值的0,如果參數(shù)中沒有數(shù)值的0,則返回按字母表順序最大的字符串。
values包含了多個值的數(shù)組。
value1Any comparable value.
value2Any comparable value.
...Any comparable value.
max() 返回參數(shù)中數(shù)值最大的值。 If multiple values can be considered of the same size, the one that is listed first will be returned.
When max() is given multiple arrays, the longest array is returned. If all the arrays have the same length, max() will use lexicographic ordering to find the return value.
When given a string it will be cast as an integer when comparing.