Understanding Arrays

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

An array is a variable that can contain multiple values. Arrays are useful when you need to store a number of values of the same type, but you don't know how many, or you don't want to create individual variables to store them all.

For example, suppose you need to store a numeric value for every day of the year. You could declare 365 separate numeric variables, but that would be a lot of work. Instead, you can create an array to store all the data in one variable. The array itself is a single variable with multiple elements; each element can contain one piece of data.

You can use loops, together with a couple of special functions for working with arrays, to assign values to or retrieve values from the various elements of an array.