php max () min () returns the maximum and minimum values _php tutorial

Source: Internet
Author: User
Max () returns the maximum value.

Grammar
Max (x, y) parameter description
X required. A number.
Y required. A number.

Description
Max () returns the value with the largest number in the parameter.

If there is only one parameter and an array, Max () returns the largest value in the array. If the first argument is an integer, a string, or a floating-point number, then at least two parameters are required and Max () returns the largest of these values. You can compare an unlimited number of values.

echo Max (1,3,5,6,7); Returns 7
echo "
";
echo Max (Array (2,4,5)); Returns 5
echo "
";
echo Max (0, ' hello '); Returns 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 a second array
Print_r ($val);
echo "
";
$val =max (' string ', Array (2,5,7), 42); Returns an array

Print_r ($val);

/*
MIN () returns the minimum value.

Grammar
Min (x, y) parameter description
X required. A number.
Y required. A number.

Description
MIN () returns the smallest value in the parameter.

If there is only one parameter and an array, min () returns the smallest value in the array. If the first argument is an integer, a string, or a floating-point number, then at least two parameters are required and min () returns the smallest of these values. Can compare infinitely multiple values

*/

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)); Returns the first array of
Print_r ($val);
echo "
";
$val =min (' string ', Array (2,5,7), 42); Returns a string
Print_r ($val);


http://www.bkjia.com/PHPjc/445383.html www.bkjia.com true http://www.bkjia.com/PHPjc/445383.html techarticle Max () returns the maximum value. The syntax max (x, y) parameter describes x required. A number. Y required. A number. Indicates that Max () returns the value that is the largest of the values in the parameter. If there is only one parameter and the ...

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