August 2003
Intermediate to advanced
1140 pages
68h 45m
English
ListValueCount
ListValueCount(list, value [, delimiters])Counts the number of times value appears
in the specified list. The search performed is case-sensitive. An
optional delimiter can be specified if the list is delimited with a
character other than the comma (the default). The following example
counts the number of times each unique value appears in the list and
outputs the results for each item:
<cfset MyList = "Apple,orange,apple,Orange,Peach,pear,apple,pear,peach,Pear,
Apple,Peach,orange,apple">
<cfset UniqueList = "">
<cfloop index="Element" list="#MyList#">
<cfif ListFind(UniqueList, Element) is "No">
<cfset UniqueList = ListAppend(UniqueList, Element)>
</cfif>
</cfloop>
<cfoutput><b>Original List:</b> #MyList#</cfoutput>
<p><cfloop index="Element" list="#UniqueList#">
<cfoutput>
#Element# appears: #ListValueCount(MyList, Element)# times.<br>
</cfoutput>
</cfloop>