What's an array?
Arrays are indexed using numbers, they usually start at 0 and go to N-1 the number of elements in an array.
What's an associative array?
Associative arrays are a key value pair, often times called a hash. Instead of using a fixed integer to index the array, you use a value, a string, to identify each element in the associative array.
Arrays in Unix
Arrays (both types) are used throughout many of the tools in Unix. AWK and Bash are 2 that you'll likely see them both used if you do any scripting work. Programming languages such as Perl, Python, and Ruby also have these data types too.
You can check out this page that shows examples of both types of arrays in AWK, titled: AWK Arrays Explained with 5 Practical Examples.
array script -
$ cat array.awk
some_array = "Hello"
some_array = "Everybody"
some_array = "!"
print some_array, some_array, some_array
Hello Everybody !
associative array -
$ cat assoc_arr.awk
debts["Kim"] = 50
debts["Roberto"] += 70
debts["Vic"] -= 30
print "Vic paid 30 dollars, but still owes", debts["Vic"]
Vic paid 30 dollars, but still owes -30
Why would I need to use one?
Arrays (both types) are extremely useful when dealing with sets of data that are related. If I have a bunch of temperature measurements from a city for say 1 month. An array would be ideal for storing these values. Storing them in an array allows the programmer to deal with them as a related set of things. If I just stored them in variables it would be much more difficult to write code to operate against the set if say I wanted to convert them from Fahrenheit to Centigrade.
Additionally there is meta data that you get for free by using this type of data structure. They automatically contain the number of elements in them, so if I needed to find out how many values were collected for the month, I'd simply have to find out the "size" of the array, or count the number of elements in it, to acquire this information.