Home >Backend Development >PHP Problem >How to query the maximum value in an array in php

How to query the maximum value in an array in php

青灯夜游
青灯夜游Original
2021-06-25 18:10:235323browse

In PHP, you can use the max() function to query the maximum value in an array. This function can obtain the maximum value in an array and return it; the syntax format is "max(array)", and the parameter array is used to specify an Array containing values.

How to query the maximum value in an array in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

In php, you can use max () function queries the maximum value in an array.

max() function returns the maximum value in an array.

Syntax:

max(array);

array: Specifies an array containing values.

Example:

<?php
$a=array(&#39;1&#39;,&#39;3&#39;,&#39;55&#39;,&#39;99&#39;);
echo max($a);
?>

Output:

99

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to query the maximum value in an array in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn