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

Name

ListContains

Synopsis

                   ListContains(list, substring [, delimiters])

Returns the index of the first element in the list that contains the specified substring as part of the element. If the substring isn’t found, 0 is returned. The search is case-sensitive. 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 returns the index of the first element in a list that contains wed:

<cfset MyList = "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday">
<cfset TheSubstring = "wed">
<cfset TheIndex = ListContains(MyList, TheSubstring)>
   
<cfoutput>
<b>List:</b> #MyList#
<p><cfif TheIndex is 0>
  The substring (#TheSubstring#) could not be found in the list!
<cfelse>
  The substring (#TheSubstring#) was found in element 
  #TheIndex# (#ListGetAt(MyList, TheIndex)#).
</cfif>
</cfoutput>

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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