arrayLen
Description
Determines the number of elements in an array.
Categories
Related
History
ColdFusion
MX: Changed behavior: This function can be used on child XML objects.
Syntax
ArrayLen(array)
Attributes
| Attribute | Description | Required | Default |
|---|---|---|---|
| array | Name of an array |
Returns
The
number of elements in 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>
The contents of the array are as follows:</p>
#myList#</p>
This array has #ArrayLen(MyArray)# elements.</p>
</cfoutput>