成人精品一区二区三区中文字幕-成人精品一区二区三区-成人精品一级毛片-成人精品亚洲-日本在线视频一区二区-日本在线视频免费

導航首頁 ? 技術(shù)教程 ? PHP:max()的用法_Math函數(shù)
全站頭部文字 我要出現(xiàn)在這里
PHP:max()的用法_Math函數(shù) 728 2024-01-01   

max

(PHP 4, PHP 5)

max — 找出最大值

說明

mixed max ( array $values ) mixed max ( mixed $value1 , mixed $value2 [, mixed $... ] )

如果僅有一個參數(shù)且為數(shù)組,max() 返回該數(shù)組中最大的值。如果第一個參數(shù)是整數(shù)、字符串或浮點數(shù),則至少需要兩個參數(shù)而 max() 會返回這些值中最大的一個。可以比較無限多個值。

Note:

PHP 會將非數(shù)值的 string 當成 0,但如果這個正是最大的數(shù)值則仍然會返回一個字符串。如果多個參數(shù)都求值為 0 且是最大值,max() 會返回其中數(shù)值的 0,如果參數(shù)中沒有數(shù)值的 0,則返回按字母表順序最大的字符串。

參數(shù)

values

包含了多個值的數(shù)組。

value1

Any comparable value.

value2

Any 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.

范例

Example #1 使用 max() 的例子

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

// When 'hello' is cast as integer it will be 0. Both the parameters are equally
// long, so the order they are given in determines the result
echo max(0, 'hello');     // 0
echo max('hello', 0);     // hello

echo max('42', 3); // '42'

// Here 0 > -1, so 'hello' is the return value.
echo max(-1, 'hello');    // hello

// With multiple arrays of different lengths, max returns the longest
$val = max(array(2, 2, 2), array(1, 1, 1, 1)); // array(1, 1, 1, 1)

// 對多個數(shù)組,max 從左向右比較。
   // 因此在本例中:2 == 2,但 4 < 5
$val = max(array(2, 4, 8), array(2, 5, 7)); // array(2, 5, 7)

// 如果同時給出數(shù)組和非數(shù)組作為參數(shù),則總是將數(shù)組視為
   // 最大值返回
$val = max('string', array(2, 5, 7), 42);   // array(2, 5, 7)
?>

參見

min() - 找出最小值 count() - 計算數(shù)組中的單元數(shù)目或?qū)ο笾械膶傩詡€數(shù)



主站蜘蛛池模板: 追凶电影| 张俪写真集照片| 小林凉子| 大珍珠演员表介绍| 马伊琍于和伟主演的电视剧| 王渝萱的电影| 美丽在唱歌 电影| 暴走财神4| 座头市电影完整免费观看| 哥哥的女人电影| 舞蹈生撕腿疼哭视频| 好好歌词| 红灯区未删减版| 王紫瑄| 女孩们在线观看| 一起来看流星雨剧照| 女公安毛片免费观看| 林东升| 孤岛惊魂| 男操女视频免费| 掩护| 电视剧《流金岁月》演员表| 江南好简谱| 包公决战潘金莲| 肖红| 柏欣彤广场舞| 涩涩免费网站| 绝伦海女| 电影《心灵奇旅》| 贝利亚抱住奥特之母完整版| 时间浪人| 电影《迷雾》完整版免费播放高清| 雅马哈调音台说明书| 亲子鉴定血型对照表| 军犬麦克斯| 恶女台剧| 牙疼图片 难受 表情包| 林祖辉| 肮脏性感的人| 中转停留| 网络谜踪|

!!!站長長期在線接?。。?/p>

網(wǎng)站、小程序:定制開發(fā)/二次開發(fā)/仿制開發(fā)等

各種疑難雜癥解決/定制接口/定制采集等

站長微信:lxwl520520

站長QQ:1737366103