value1,key2=>value2...,keyN=>valueN);"; 2. Use max() to obtain The maximum value of the array has been defined, the syntax is "max($array variable name)".">
Method: 1. Use array() to define and initialize the array. The syntax is "$array variable name=array(key1=>value1,key2=>value2...,keyN=>valueN); "; 2. Use max() to obtain the maximum value of the defined array, the syntax is "max($array variable name)".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Define in php language A method to find the maximum value of an array
Step 1. Use the array() function to define and initialize the array
You can use array() function to create a new array. It accepts a certain number of key=>value parameter pairs separated by commas. The syntax format is as follows:
$数组变量名 = array(key1 => value1, key2 => value2, ..., keyN => valueN);
key can be omitted, that is, you can not use the=>
symbol to specify the subscript, and the default is the index array. The default index value also starts from 0 and increases in sequence.
Step 2. Use the built-in function max() to get the maximum value of the array
max() function can return an array The maximum value in
echo "数组最大值为: ".max($arr)."
";
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to define an array and find the maximum value in php language. For more information, please follow other related articles on the PHP Chinese website!