View comments | RSS feed

ArrayLen

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 Using XML and WDDX in ColdFusion MX Developer's Guide

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>#myList#
   <p>This array has #ArrayLen(MyArray)# elements.
</cfoutput>

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


No screen name said on Jun 9, 2005 at 9:10 PM :
Maybe this is obvious to many but....

to get the length of the second dimension of a two dimensional array myArray[i][j]:

L = arraylen(myArray[1])
BlueSpline said on Oct 31, 2006 at 10:41 PM :
If you have a three dimensional array - xxArray - then

ArrayLen(xxArray[1]) gives the length of the first dimension
ArrayLen(xxArray) gives the length of the second dimension
ArrayLen(xxArray[1][1]) gives the length of the third dimension

Not quite intuitive.

HTH, Mike

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000387.htm