Name

ListValueCountNoCase

Synopsis

                  ListValueCountNoCase(list, value [, delimiters])

Counts the number of times value appears in the specified list. The search performed is case-insensitive. An optional delimiter can be specified if the list is delimited with a character other than the comma (the default). Here’s an example that 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 ListFindNoCase(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: #ListValueCountNoCase(MyList, Element)# times 
    regardless of case.<br>
  </cfoutput>
</cfloop>

Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.