Adobe ColdFusion 8

ArrayIsEmpty

Description

Determines whether an array is empty of data elements.

Returns

True, if the array is empty; False, otherwise.

Category

Array functions

Function syntax

ArrayIsEmpty(array)

See also

ArrayIsDefined, ArrayLen, "Functions for XML object management" in the ColdFusion Developer's Guide

History

ColdFusion MX: Changed behavior: this function can be used on XML objects.

Parameters

Parameter

Description

array

Name of an array

Usage

You can test whether an element of a higher level dimension of a multidimensional array is empty by specifying the element in the ArrayIsEmpty function. To test whether the first row of the two-dimensional array MyArray is empty, use the following function:

ArrayIsEmpty(MyArray2[1])

Example

<h3>ArrayIsEmpty Example</h3>
<!--- Create a new array. --->
<cfset MyArray = ArrayNew(1)>
<!--- Populate an element or two. --->
<cfset MyArray[1] = "Test">
<cfset MyArray[2] = "Other Test">
<!--- Output the contents of the array. --->
<p>Your array contents are:
<cfoutput>#ArrayToList(MyArray)#</cfoutput>
<!--- Check to see if the array is empty. --->
<p>Is the array empty?:
<cfoutput>#ArrayIsEmpty(MyArray)#</cfoutput>
<p>Now, clear the array:
<!--- Now clear the array. --->
<cfset Temp = ArrayClear(MyArray)>
<!--- Check to see if the array is empty. --->
<p>Is the array empty?:
<cfoutput>#ArrayIsEmpty(MyArray)#</cfoutput>