Phpmax () min () returns the maximum and minimum values.

Source: Internet
Author: User
Max () returns the maximum value syntax: the max (x, y) parameter description x is required, a number. y is required. it is a number. note: max () returns the maximum value of a parameter. if there is only one parameter and it is an array, max () returns... max () returns the maximum value.

Syntax:Max (x, y)

Parameter description

X is required. it is a number.

Y is required. it is a number.

Note:Max () returns the maximum value of a parameter.

If there is only one parameter and it is an array, max () returns the maximum value of the array. if the first parameter is an integer, string, or floating-point number, at least two parameters are required, while max () the maximum value of these values is returned, which can be an unlimited number of values. the instance code is as follows:

Echo max (1, 3, 5, 6, 7); // return 7 echo"
"; Echo max (array (2, 4, 5); // returns 5 echo"
"; Echo max (0, 'Hello'); // return 0 echo"
"; Echo max ('hello', 0); // return hello echo"
"; Echo max (-1, 'Hello'); // return hello echo"
"; $ Val = max (array (2, 4, 8), array (2, 5, 7); // returns the second array print_r ($ val); echo"
"; $ Val = max ('string', array (, 7), 42); // returns an array

Min () returns the minimum value.

Syntax:Min (x, y)

Parameter description

X is required. it is a number.

Y is required. it is a number.

Note:Min () returns the smallest value in the parameter.

If there is only one parameter and it is an array, min () returns the smallest value in the array. if the first parameter is an integer, string, or floating-point number, at least two parameters are required and min () returns the smallest of these values. you can compare them with an infinite number of values. the instance code is as follows:

Echo min (2, 3, 1, 6, 7); // 1 echo"
"; Echo min (array (2, 4, 5); // 2 echo"
"; Echo min (0, 'Hello'); // 0 echo"
"; Echo min ('hello', 0); // hello echo"
"; Echo min ('hello',-1); //-1 echo"
"; $ Val = min (array (2, 4, 8), array (2, 5, 1); // return the first array print_r ($ val); echo"
"; $ Val = min ('string', array (2, 5, 7), 42); // return string print_r ($ val );


Tutorial address:

Reprinted! But please include the article address ^

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.