– Common Function Library Project

ArrayFindByDimension(arrayToSearch, valueToFind, dimensionToSearch)

Last updated September 23, 2004


Grant Szabo

Version: 1 | Requires: CF6 | Library: DataManipulationLib

Extends Nathan Dintenfass' ArrayFindNoCase() by adding ability to search a specified dimension of a multidimensional array. Returns numeric array position of first dimension if element found, otherwise returns 0.

Return Values:
Returns a number.


arr = arrayNew(2);
arr[1][1] = "apple";
arr[1][2] = "pear";
arr[1][3] = "orange";
arr[2][1] = "star";
arr[2][2] = "nova";
arr[2][3] = "moon";

writeOutput(arrayFindByDimension(arr,"star",1) & "<br>");            
writeOutput(arrayFindByDimension(arr,"star",2) & "<br>");            



Name Description Required
arrayToSearch Array to search. Yes
valueToFind Value to find. Yes
dimensionToSearch Dimension to search. Yes

Full UDF Source:

 Search a multidimensional array for a value.
 @param arrayToSearch      Array to search. (Required)
 @param valueToFind      Value to find. (Required)
 @param dimensionToSearch      Dimension to search. (Required)
 @return Returns a number. 
 @author Grant Szabo ( 
 @version 1, September 23, 2004 
<cffunction name="ArrayFindByDimension" access="public" returntype="numeric" output="false">
    <cfargument name="arrayToSearch" type="array" required="Yes">
    <cfargument name="valueToFind" type="string" required="Yes">
    <cfargument name="dimensionToSearch" type="numeric" required="Yes">
        var ii = 1;
        //loop through the array, looking for the value
        for(; ii LTE arrayLen(arguments.arrayToSearch); ii = ii + 1){
            //if this is the value, return the index
            if(NOT compareNoCase(arguments.arrayToSearch[ii][arguments.dimensionToSearch], arguments.valueToFind))
                return ii;
        //if we've gotten this far, it means the value was not found, so return 0
        return 0;


Latest Additions

Raymond Camden added
November 04, 2017

Leigh added
May 11, 2016

Raymond Camden added
May 10, 2016

Kevin Cotton added
May 05, 2016

Raymond Camden added
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson