ColdFusion UDF Library - arrayFind
December 16th, 2008
«« Back to ColdFusion Library
Category:
ARRAY
Description:
Searches an array and returns the position of a value.
Parameters:
Returns:
(Numeric) The last position at which the value is found. Or zero if it is not found.
Requires:
Sample Use:
Copy to Clipboard
Category:
ARRAY
Description:
Searches an array and returns the position of a value.
Parameters:
- array (Array, required)
The array to perform the operation on. - value (String, required)
The value in the array to find. - start (Numeric, Default: 1)
The start postion of the array to begining peforming the search. - ignorePos (List, Default: )
A list of postions to ignore when searching the array.
Returns:
(Numeric) The last position at which the value is found. Or zero if it is not found.
Requires:
Sample Use:
Copy to Clipboard
function arrayFind(array,value){
var loop = 0;
var len = arrayLen(array);
var pos = 0;
var start = 1;
var ignorePos = "";
if (arrayLen(arguments) gte 3)start = arguments[3];
if (arrayLen(arguments) gte 4)ignorePos = arguments[4];
for (loop = start; loop lte len; loop = incrementValue(loop))if (array[loop] eq value and not listFindNoCase(ignorePos,loop))pos = loop;
return pos;
}
// http://www.programmers.org/index.php/coldfusion-udf-library/?ckey=82&function=arrayFind



