ArrayContains(arrayToSearch, valueToFind)
Last updated March 31, 2003
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);
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016