ArrayListCompareNoCase(arrayToSearch, listToFind[, delimiter])
Last updated March 28, 2005
Version: 1 | Requires: CF5 | Library: DataManipulationLib
Description:
Returns the index in an array containing one of the given (case-insensitive) list elements or 0 if none found.
Return Values:
Returns a number.
Example:
<cfset l = "a,b,c,d">
<cfset a = ArrayNew(1)>
<cfset a[1] = "e">
<cfset a[2] = "d">
<cfset a[3] = "ab">
<cfoutput>#ArrayListCompareNoCase(a, l)#</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
arrayToSearch | The array to search. | Yes |
listToFind | List that will be searched for. If any item is found, the array index is returned. | Yes |
delimiter | List delimiter. Defaults to a comma. | No |
Full UDF Source:
/**
* Returns the index of the first item in an array that contains a list element.
*
* @param arrayToSearch The array to search. (Required)
* @param listToFind List that will be searched for. If any item is found, the array index is returned. (Required)
* @param delimiter List delimiter. Defaults to a comma. (Optional)
* @return Returns a number.
* @author Steve Robison, Jr (steverobison@gmail.com)
* @version 1, March 28, 2005
*/
function ArrayListCompareNoCase(arrayToSearch,listToFind){
//a variable for looping
var ii = 0; // variable for looping through list
var jj = 0; // variable for looping through array
var delimiter = ','; // default delimiter
// check to see if delimiters were passed
if (ArrayLen(arguments) gt 2) delimiter = arguments[3];
//loop through list
for(ii = 1; ii LTE ListLen(listToFind, delimiter); ii = ii + 1) {
//loop through the array, looking for the value
for(jj = 1; jj LTE arrayLen(arrayToSearch); jj = jj + 1){
//if this is the value, return the index
if(NOT compareNoCase(arrayToSearch[jj],ListGetAt(listToFind, ii, delimiter)))
return jj;
}
}
//if we've gotten this far, it means the value was not found, so return 0
return 0;
}
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