ArrayIsDefined Example
Here is an example to show the usage of ArrayIsDefined function in CF8.
This function determines whether an array element is defined.
Returns YES, if the array element is defined (exists). Returns NO, if the array element is NOT defined.
Function syntax: ArrayIsDefined(array, elementIndex)
<cfset MyArray = ArrayNew(1)>
<!--- Populate the array --->
<cfset MyArray[1] = "First Element">
<cfset MyArray[3] = "Third Element">
<!--- Display the contents of the array --->
<p>
Your array contents are:
<cfdump var="#MyArray#">
</p>
<cfoutput>
<!--- Check if the elements are defined. --->
<p>Does element 1 exist?
#ArrayIsDefined(MyArray, 1)#
<p>Does element 2 exist?
#ArrayIsDefined(MyArray, 2)#
<p>Does element 3 exist?:
#ArrayIsDefined(MyArray, 3)#</p>
</cfoutput>
Note: This function currently throws an error if the array is NOT initialized.
So if the array is not yet created, you should surround the ArrayIsDefined code in a
You can download the cfm code using the download button.

There are no comments for this entry.
[Add Comment]