Introduction to Using Arrays in ColdFusion MX
- Introduction
- Creating an Array
- Adding an Element to an Array
- Displaying a Value in an Array
- Looping over an Array
- Manipulating Array Values
- Sorting an Array
- Multidimensional Arrays
- Creating Arrays with More Than Three Dimensions
- Array Aggregate Functions
- Array Utility Functions
- Array Information Functions
3.0. Introduction
An array is a data type containing an ordered collection of variables. Items in an array are referred to as array elements and are referenced by their index (or numerical position) in the array.
You use arrays when you have a collection of variables and need to store them in a defined order. Like lists (discussed in Chapter 2, "Working with Lists"), arrays support variable orderyou can explicitly reference the value stored in a given position of the array. Although lists only store simple variables like strings and numbers, arrays can store complex data types, such as structures, queries, and even other arrays. If you need to store complex data types in a collection but do not need them in a defined order, you may want to look into using the ColdFusion data type structure, discussed in Chapter 4, "Structures."
This chapter shows you how to iterate over array element values, manipulate element values, and sort an array. It also explains how and when to use multidimensional arrays and how and when to use array aggregate functions.