Used to determine if a value is in the given array, case-sensitive. Adobe CF and OpenBD return boolean. Lucee / Railo returns the numeric index if the value is found, 0 if not.
arrayContains(array, value)
returns boolean
someArray.contains(value)
Name | Type | Required | Default | Description |
---|---|---|---|---|
array | array | Yes | The array in which to search. | |
value | any | Yes | The value to search for in the array. | |
substringMatch | any | No | false | Lucee4.5+ If set to true then a substring match will also return an array position. This will only work with simple values. Passing true with complex objects will throw an exception. |
CF9+
someArray = [1,2,3];
writeDump(arrayContains(someArray,2));
CF10+
someArray = [1,2,3];
writeDump(someArray.contains(2));
Lucee4.5+
someArray = [1,2,3];
writeDump(arrayContains(someArray,2));
Lucee4.5+
someArray = [1,2,3];
writeDump(someArray.contains(2));
Lucee4.5+
words = [ 'hello' , 'world' ];
positionOfSubstring = arrayContains( words, 'el', true );
writeDump(positionOfSubstring);