| LISTLEN | |||||||||||||||||||
| Description
Determines the number of elements in a list. Integer; the number of elements in a list. |
|||||||||||||||||||
| Category
List functions |
|||||||||||||||||||
Function syntaxListLen(list [, delimiters ]) |
|||||||||||||||||||
| See also
ListAppend, ListDeleteAt, ListInsertAt, ListPrepend; "Lists" in Chapter 3, "Using ColdFusion Variables," in ColdFusion MX Developer's Guide |
|||||||||||||||||||
| Parameters
|
|||||||||||||||||||
| Usage
ColdFusion ignores empty list elements; thus, the list "a,b,c,,,d" has four elements. Here are some examples of ListLen processing:
|
|||||||||||||||||||
Example<h3>ListLen Example</h3>
<!--- Find a list of users who wrote messages --->
<cfquery name = "GetMessageUser" datasource = "cfdocexamples">
SELECT Username, Subject, Posted
FROM Messages
</cfquery>
<cfset temp = ValueList(GetMessageUser.Username)>
<!--- loop through the list and show it with ListGetAt --->
<h3>This is a list of usernames who have posted messages
<cfoutput>#ListLen(temp)#</cfoutput> users.</h3>
<ul>
<cfloop From = "1" TO = "#ListLen(temp)#" INDEX = "Counter">
<cfoutput><li>Username #Counter#:
#ListGetAt(temp, Counter)#</cfoutput>
</cfloop>
</ul>
|
|||||||||||||||||||
| LIST | |
| DELIMITERS | |