Tuesday, December 11, 2007

Function ArrayIsDefined() in CF8

This is a new function added in CF8, this function determines whether an array element is defined. This returns true, if the array element is defined (exists); false, otherwise.

Function syntax

ArrayIsDefiend(array, elementIndex)  

Parameters

Parameter

Description

array

Name of a one dimensional array, or the array name and indexes into higher-order dimensions of a multidimensional array.

elementIndex 

Index of the element in a one dimensional array, or the index of the element in the final dimension of a multidimensional array.

Usage

To test the existence of an element in a multidimensional array, specify all but the last dimension of the array in the first parameter. For example, the following line tests the existence of element MyArray[2][4][1]:

ArrayIsDefined(MyArray[2][4], 1)  

Example

<h3>ArrayIsDefined Example</h3> <!--- Create a sparse new array. ---> <cfset MyArray = ArrayNew(1)> <!--- Populate an element or two. ---> <cfset MyArray[1] = "Test"> <cfset MyArray[3] = "Other Test">  <cfoutput>     <!--- Display the contents of the array. --->     <p>Your array contents are:     <cfdump var="#MyArray#"></p>          <!--- Check if an existing element is defined. --->     <p>Does element 3 exist?:&nbsp;     #ArrayIsDefined(MyArray, 3)#</p>          <!--- Check if a non-existent element is defined. --->     <p>Does element 2 exist?&nbsp;     #ArrayIsDefined(MyArray, 2)# </cfoutput> 

5 comments:

jones said...

Nice blog...
visit also coldfusion example

Anonymous said...

Plеasе let me knоω if уou're looking for a article author for your weblog. You have some really good articles and I think I would be a good asset. If you ever want to take some of the load off, I'd
reallу liκe to ωrite some mateгial for youг blog in exchange for a link bаck tο mine.
Please send me an emаil if intereѕted. Regards!



Feel free to surf to mу ωebsite; blok oyunları
Also see my page - en yeni oyunlar

Anonymous said...

Thanks a lot for sharing this with all of us you actually realize what you're talking about! Bookmarked. Please additionally consult with my website =). We can have a hyperlink trade contract among us

Also visit my webpage; affiliate

Anonymous said...

Ιnformative artісle, just what Ӏ waѕ looking for.


Feel free tο visit my web site ... ev oyunları

Anonymous said...

Thіѕ is mу first time ρay a quick νisit
at hегe and i am in faсt happy tο гead eveгthing аt аlone place.


Fеel fгee to viѕit my ωeb-site .
.. canlı radyo