cfdocs

listLen

Determines the number of elements in a list.

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

Argument Reference

Name Type Required Default Description
list string Yes   A list or a variable that contains one
delimiters string No , 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 No NO CF10+ 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.

Simple listLen Example

Get the number of elements in this list

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

Expected Result: 4

listLen Example with Delimiter

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

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

Expected Result: 3

listLen Example with IncludeEmptyValues

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

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

Expected Result: 4