Associative Arrays?

You can use string values as keys. For example, you might create an array
like this:

$myStuff = array();
$myStuff[“name”] = “andy”;
$myStuff[“email”] = “andy@fsdsd.ca”;
Print $myStuff[“name”];

Associative arrays are different than normal (numeric-indexed) arrays in
some subtle but important ways:
The order is undefined. Regular arrays are always sorted based on the
numeric index. You don’t know what order an associative array will be
because the keys aren’t numeric.

 You must specify a key. If you’re building a numeric-indexed array, PHP
can always guess what key should be next. This isn’t possible with an
associative array.

 Associative arrays are best for name-value pairs. Associative arrays are
used when you want to work with data that comes in name/value pairs.
This comes up a lot in PHP and XHTML. XHTML attributes are often in
this format, as are CSS rules and form input elements.

✦ Some of PHP’s most important values are associative arrays. The $_
REQUEST variable (described in Chapter 3 of this minibook) is an important
associative array. So are $_GET, $_POST, and several others.

Make sure to include quotation marks if you’re using a string as an array
index.