CFLib.org – Common Function Library Project

ArrayFindNoCase(arrayToSearch, valueToFind)

Last updated September 06, 2002

author

Nathan Dintenfass

Version: 1 | Requires: CF5 | Library: DataManipulationLib

Description:
Returns the index in an array containing a given (case-insensitive) value. It is analagous to listFind(), but with arrays. See also arrayFind().

Return Values:
Returns a number.

Example:

<cfscript>
    anArray = arrayNew(1);
    anArray[1] = "Camden";
    anArray[2] = "Archibald";
    anArray[3] = "Mueller";
    anArray[4] = "Dintenfass";
</cfscript>

<cfoutput>#arrayFindNoCase(anArray,"MUELLER")#</cfoutput>

Parameters:

Name Description Required
arrayToSearch The array to search. Yes
valueToFind The value to look for. Yes

Full UDF Source:

/**
 * Like listFindNoCase(), but for arrays.
 * 
 * @param arrayToSearch      The array to search. (Required)
 * @param valueToFind      The value to look for. (Required)
 * @return Returns a number. 
 * @author Nathan Dintenfass (nathan@changemedia.com) 
 * @version 1, September 6, 2002 
 */
function ArrayFindNoCase(arrayToSearch,valueToFind){
    //a variable for looping
    var ii = 0;
    //loop through the array, looking for the value
    for(ii = 1; ii LTE arrayLen(arrayToSearch); ii = ii + 1){
        //if this is the value, return the index
        if(NOT compareNoCase(arrayToSearch[ii],valueToFind))
            return ii;
    }
    //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

Created by Raymond Camden / Design by Justin Johnson