ArrayContains

Description

Searches the array for an element. It does not support COM and CORBA objects. This function performs a case-sensitive comparison of string values.

Returns

Yes, if the element being searched, exists in the array.

Function Syntax

#ArrayContains(array,object)

Parameters

Parameter

Description

array

Name of the array.

object

Object to search

Example

<h3>ArrayContains Example</h3> 
<h3>2-dimensional array example</h3> 
<!--Creating a 2-dimensional array- - > 
 
<cfset dayarray = ArrayNew(2)> 
<cfset dayarray[1][1] = "Sunday">  
<cfset dayarray[1][2] = "Monday"> 
<cfset dayarray[1][3] = "Tuesday"> 
<cfset dayarray[2][1] = "Wednesday"> 
<cfset dayarray[2][2] = "Thursday"> 
<cfset dayarray[2][3] = "Friday"> 
 
<cfoutput> 
    <p>Array contains</p> 
    #dayarray[1][1]#, #dayarray[1][2]#, #dayarray[1][3]#, #dayarray[2][1]#,      
    #dayarray[2][2]#, #dayarray[2][3]# 
    <p>Checking value in the array</p> 
    #ArrayContains(dayarray[1], "Tuesday")#</cfoutput> 
<!--Creating a one-dimensional array--> 
<h3>1-dimensional array example</h3> 
<cfset montharray = ArrayNew(1)> 
<cfset montharray[1] = "April"> 
<cfset montharray[2] = "July"> 
<cfset montharray[3] = "October"> 
<cfset montharray[4] = "December"> 
<p>Checking if value exists</p> 
<cfoutput> 
    #ArrayContains(montharray, "December")# 
</cfoutput>