CFLib.org – Common Function Library Project

ArrayContains(arrayToSearch, valueToFind)

Last updated March 31, 2003

author

Sudhir Duddella

Version: 1 | Requires: CF5 | Library: DataManipulationLib

Description:
Returns the index of the first item that contains a specified substring. The search is case-sensitive. If the substring is not found in an Array, it returns zero (0).

Return Values:
Returns a number.

Example:

<cfset arrN = arrayNew(1)>
<cfset arrN[1] = "A">
<cfset arrN[2] = "AP">
<cfset arrN[3] = "B">
<cfset arrN[4] = "APPLE">
<cfset arrN[5] = "BOY">
<cfset arrN[6] = "BOUGHT">

<cfoutput>#ArrayContains(arrN,"OU")#</cfoutput>

Output:
6

Parameters:

Name Description Required
arrayToSearch Array to search. Yes
valueToFind Value to look for. Yes

Full UDF Source:

/**
 * Returns the index of the first item in an array that contains a specified substring.
 * Mods by RCamden
 * 
 * @param arrayToSearch 	 Array to search. (Required)
 * @param valueToFind 	 Value to look for. (Required)
 * @return Returns a number. 
 * @author Sudhir Duddella (skduddella@hotmail.com) 
 * @version 1, March 31, 2003 
 */
function ArrayContains(arrayToSearch,valueToFind){
	var arrayList = "";

	arrayList = ArrayToList(arrayToSearch);
	return ListContains(arrayList,valueToFind);				
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson