User Guide Cancel

ListLen

 

Description

Determines the number of elements in a list. Integer; the number of elements in a list.

Category

List functions

Function syntax

ListLen(list [, delimiters ])
ListLen(list [, delimiters, includeEmptyFields ])
ListLen(list [, delimiters ]) ListLen(list [, delimiters, includeEmptyFields ])
ListLen(list [, delimiters ]) 
ListLen(list [, delimiters, includeEmptyFields ])

See also

ListAppendListDeleteAtListInsertAtListPrependLists in Data types- Developing guide in the Developing ColdFusion Applications

Parameters

Parameter

Description

list

A list or a variable that contains one.

delimiters

A string or a variable that contains one. Characters that separate list elements. The default value is comma. If this parameter contains more than one character, ColdFusion processes each occurrence of each character as a delimiter.

includeEmptyFields

If includeEmptyValues is set to true, all empty values in the list will be considered when computing length. If set to false, the empty list elements are ignored.

Usage

ColdFusion ignores empty list elements; thus, the list "a,b,c,,,d" has four elements.Here are some examples of ListLen processing:

Statement

Output

Comment

ListLen('a,b, c,,,d')

4

Third element is " c"

ListLen('a,b, c,,,d',',')

4

Fourth element is "d'"

ListLen('elem_1__elem_2__elem_3')

1

 

ListLen('elem*1**elem*2**elem*3')

1

 

ListLen('elem_1__elem_2_elem_3','')

6

 

ListLen("1,,3", ",", true) 3  

Example

<cfscript>
myList="Tokyo,Bangkok,Jakarta,Manila,Bangalore,Shanghai";
outputLen=ListLen(myList);
WriteOutput(outputLen); // Returns 6
</cfscript>
<cfscript> myList="Tokyo,Bangkok,Jakarta,Manila,Bangalore,Shanghai"; outputLen=ListLen(myList); WriteOutput(outputLen); // Returns 6 </cfscript>
<cfscript>
       myList="Tokyo,Bangkok,Jakarta,Manila,Bangalore,Shanghai";
       outputLen=ListLen(myList);
       WriteOutput(outputLen); // Returns 6
</cfscript>

Output

6

Get help faster and easier

New user?