How to get the sum of values of an array in ColdFusion

ArraySum() - get sum of values in an array


<!DOCTYPE html>

<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ArraySum function example: how to get sum of values in an array</title>

<h2 style="color:Green">ArraySum Function Example</h2>

<cfset NumberArray = ArrayNew(1)>
<cfset Temp = Arrayprepend(NumberArray,10)>
<cfset Temp = Arrayprepend(NumberArray,20)>
<cfset Temp = Arrayprepend(NumberArray,30)>
<cfset Temp = Arrayprepend(NumberArray,40)>
<cfdump var="#NumberArray#" label="NumberArray">

<br />
<cfoutput><b>NumberArray[Sum]: #ArraySum(NumberArray)#</b></cfoutput>

More ColdFusion examples