How to get total number of elements in an array in ColdFusion

ArrayLen() - get total number of elements in an array

ArrayLen.cfm


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ArrayLen function example: how to get total number of elements in an array</title>
</head>

<body>
<h2 style="color:hotpink">ArrayLen Function Example</h2>

<cfset ColorArray = ArrayNew(1)>
<cfset Temp = ArrayPrepend(ColorArray,"DarkCyan")>
<cfset Temp = ArrayPrepend(ColorArray,"DarkGoldenRod")>
<cfset Temp = ArrayPrepend(ColorArray,"DarkGray")>
<cfdump var="#ColorArray#" label="Color Array">

<br />
<cfoutput><b>ColorArray Length: #ArrayLen(ColorArray)#</b></cfoutput>
</body>
</html>






More ColdFusion examples