Description

Determines the number of elements in an array.

Returns

The number of elements in an array.

Category

Array functions

Function syntax

arrayLen(array)

See also

ArrayIsEmpty; Functions for XML object management in Modifying a ColdFusion XML object in the Developing ColdFusion Applications

History

ColdFusion MX: Changed behavior: This function can be used on child XML objects.

Parameters

Parameter

Description

array

Name of an array

Example

<h3>arrayLen Example</h3>
<cfquery name = "GetEmployeeNames" datasource = "cfdocexamples">
SELECT FirstName, LastName FROM Employees
</cfquery>
<!--- Create an array. --->
<cfset myArray = arrayNew(1)>
<!--- Set element one to show where we are. --->
<cfset myArray[1] = "Test Value">
<!--- Loop through the query and append these names
successively to the last element. --->
<cfloop query = "GetEmployeeNames">
<cfset temp = ArrayAppend(myArray, "#FirstName# #LastName#")>
</cfloop>
<!--- Show the resulting array as a list. --->
<cfset myList = arrayToList(myArray, ",")>
<!--- Output the array as a list. --->
<cfoutput>
<p>The contents of the array are as follows:</p>
<p>#myList#</p>
<p>This array has #arrayLen(MyArray)# elements.</p>
</cfoutput>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy