listLen

Determines the number of elements in a list.

listLen(list [, delimiters, [includeEmptyValues]]) → returns numeric

Argument Reference

list string
Required

A list or a variable that contains one

delimiters string
Default: ,

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.

includeEmptyValues string
Default: NO

CF 10+ 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.

Examples
Sample code invoking the listLen function

Get the number of elements in this list

listLen("foo,bar,bar2,foo2")

Expected Result: 4

Get the number of elements in this list using a custom delimiter

listLen("foo,bar|bar2|foo2", "|")

Expected Result: 3

Get the number of elements in this list, including empty values

listLen("foo,bar,,foo2", ",", "YES")

Expected Result: 4

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub