ColdFusion structures consist of key-value pairs. Structures let you build a collection of related variables that are grouped under a single name. You can define ColdFusion structures dynamically.
You can use structures to refer to related values as a unit rather than individually. To maintain employee lists, for example, you can create a structure that holds personnel information such as name, address, phone number, ID numbers, and so on. Then you can refer to this collection of information as a structure called employee rather than as a collection of individual variables.
A structure's key must be a string. The values associated with the key can be anything; for example, a string, an integer, an array, or another structure. Because structures can contain both structures and arrays, they provide a very powerful and flexible mechanism for representing complex data.
You can use structures as associative arrays. When used as associative arrays, structures index repetitive data by string keys rather than by integers. For example, you might use structures to create an associative array that matches people's names with their departments. In this example, a structure named Departments includes an employee named John, listed in the Sales department. To access John's department, you would use the syntax, Departments["John"]
.
ColdFusion supports three types of notation for structures. Which notation you use depends on your needs: