ArrayMax

Description

Array maximum function.

Returns

The largest numeric value in an array. If the array parameter value is an empty array, returns zero.

Function syntax

ArrayMax(array)

Parameters

Parameter

Description

array

Name of an array

Example

<h3>ArrayMax Example</h3> 
<p>This example uses ArrayMax to find the largest number in an array.<br> </p> 
<!--- After checking whether the form has been submitted, the code creates an array 
    and assigns the form fields to the first two elements in the array. ----> 
<cfif IsDefined("FORM.submit")> 
    <cfset myNumberArray = ArrayNew(1)> 
    <cfset myNumberArray[1] = number1> 
    <cfset myNumberArray[2] = number2> 
    <cfif Form.Submit is "Maximum Value">     
        <!--- Use ArrayMax to find the largest number in the array. ---> 
        <p>The largest number that you entered is 
        <cfoutput>#ArrayMax(myNumberArray)#.</cfoutput> 
    </cfif>     
</cfif>     
<!---- The following form provides two numeric fields that are compared when the 
    form is submitted. ---> 
<form action = "arraymax.cfm"> 
    <input type = "hidden" name = "number1_Float"> 
    <input type = "hidden" name = "number2_Float"> 
    <input type = "text" name = "number1"><br> 
    <input type = "text" name = "number2"><br> 
    <input type = "submit" name = "submit" value = "Maximum Value"> 
</form>