Returns the length of an array.
ArrayLen(array)
Parameter |
Description |
---|---|
array |
Name of an array whose length to return |
<!--- This example shows ArrayLen ---> <html> <head> <title>ArrayLen Example</title> </head> <body> <H3>ArrayLen Example</H3> <cfquery name = "GetEmployeeNames" datasource = "cfsnippets"> 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> </body> </html>