• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Name

ListValueCount

Synopsis

                  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>

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint