Traditionally, an array is a tabular structure used to hold data, much like a spreadsheet table with clearly defined limits and dimensions.
In ColdFusion, you typically use arrays to temporarily store data. For example, if your site lets users order goods online, you can store their shopping cart contents in an array. Using an array lets you make changes easily without committing the information, which the user can change before completing the transaction, to a database.
Basic array concepts
Subsequent discussions of ColdFusion arrays are based on the following terms:
- Array dimension The relative complexity of the array structure.
- Index The position of an element in a dimension, ordinarily surrounded by brackets: my1Darray1, my2Darray11, my3Darray111.
- Array element: Data stored at an array index. The simplest array is a one-dimensional array, like a row in a table. A one-dimensional array has a name (the variable name) and a numeric index. The index number references a single entry, or cell, in the array.
Thus, the following statement sets the value of the fifth entry in the one-dimensional array MyArray to "Robert":