![MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Скачать руководство пользователя страница 132](http://html1.mh-extra.com/html/macromedia/coldfusion-4-5-developing-web/coldfusion-4-5-developing-web_develop-manual_3286369132.webp)
106
Developing Web Applications with ColdFusion
Multidimensional Arrays
ColdFusion supports dynamic multidimensional arrays. When you declare an array
with the ArrayNew function, you can specify up to three dimensions. However, you can
increase an array’s dimensions by nesting arrays as array elements:
<CFSET myarray=ArrayNew(1)>
<CFSET myotherarray=ArrayNew(2)>
<CFSET biggerarray=ArrayNew(3)>
<CFSET biggerarray[1][1][1]=myarray>
<CFSET biggerarray[1][1][1][10]=
some_value
>
<CFSET biggerarray[2][1][1]=myotherarray>
<CFSET biggerarray[2][1][1][4][2]=
some_value
>
<CFSET biggestarray=ArrayNew(3)>
<CFSET biggestarray[3][1][1]=biggerarray>
<CFSET biggestarray[2][1][1][2][3][1]=
some_value
>
Basic Array Techniques
To use arrays in ColdFusion, as in other languages, you need to first declare the array,
specifying its dimension. Once it’s declared, you can add array elements, which you
can then reference by index.
As an example, say you declare a one-dimensional array called "firstname:"
<CFSET firstname=ArrayNew(1)>
At first, the array firstname holds no data and is of an unspecified length. Now you
want to add data to the array:
<CFSET firstname[1]="Coleman">
<CFSET firstname[2]="Charlie">
<CFSET firstname[3]="Dexter">
Once you’ve added these names to the array, it has a length of 3:
<CFSET temp=ArrayLen(firstname)>
<!--- temp=3 --->
If you remove data from an index, the array resizes dynamically:
<CFSET temp=ArrayDeleteAt(firstname, 2)>
<!--- "Charlie" has been removed from the array --->
<CFOUTPUT>
The firstname array is #ArrayLen(firstname)#
indexes in length
</CFOUTPUT>
<!--- Now the array has a length of 2, not 3 --->
The array now contains:
Содержание COLDFUSION 4.5-DEVELOPING WEB
Страница 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Страница 14: ...xiv Developing Web Applications with ColdFusion...
Страница 26: ...xxvi Developing Web Applications with ColdFusion...
Страница 34: ...8 Developing Web Applications with ColdFusion...
Страница 70: ...44 Developing Web Applications with ColdFusion...
Страница 84: ...58 Developing Web Applications with ColdFusion...
Страница 114: ...88 Developing Web Applications with ColdFusion...
Страница 148: ...122 Developing Web Applications with ColdFusion...
Страница 174: ...148 Developing Web Applications with ColdFusion...
Страница 208: ...182 Developing Web Applications with ColdFusion...
Страница 244: ...218 Developing Web Applications with ColdFusion...
Страница 274: ...248 Developing Web Applications with ColdFusion...
Страница 288: ...262 Developing Web Applications with ColdFusion...
Страница 300: ...274 Developing Web Applications with ColdFusion...
Страница 350: ...324 Developing Web Applications with ColdFusion...
Страница 362: ...336 Developing Web Applications with ColdFusion...