PHP-Associative Array

When you are building an ordinary array, the array function requires
 the data, but doesn't require you to specify the indices.
It automatically generates the index of each element by grabbing
the next available integer. In an associative array, you are responsible
 for providing both the data and the index. The general format for this
 assignment uses a special kind of assignment operator. The => operator
 indicates an element holds some kind of value.


The foreach loop is just as useful with associative arrays as it
 is with the vanilla kind. However, it uses a slightly different syntax.
 Take a look at this code :

foreach ($test as $ctest => $catest){
  print "$ctest: $catest<br>\n";
} // end foreach

A foreach loop for a regular array uses only one variable because the
 index can be easily calculated. In an associative array, each element
 in the array will have a unique index and value.

The associative form of the foreach loop takes this into account
by indicating two variables. The first variable holds the index.
The second variable refers to the value associated with that index.
 Inside the loop, you can refer to the current index and value using
whatever variable names you designated in the foreach structure.

Unlike traditional arrays, you cannot rely on associative arrays
to return in any particular order when you use a foreach loop to
access elements of the array. If you need elements to show up in
a particular order, you'll need to call them explicitly.


PHP is known for its extremely flexible arrays. You can easily generate
 a number of interesting and useful array types in addition to the
ordinary arrays you've already made. One of the handiest types of
arrays is called an associative array.

While it sounds complicated, an associative array is much like a
 normal array. While regular arrays rely on numeric indices,
an associative array has a string index.