note 11507 added to Variables
| From: | php dot net at chiefworks dot com | Date: | Thu, 22 Feb 2001 22:40:20 +0000 |
| Subject: | note 11507 added to Variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-11440@lists.php.net to get a copy of this message | ||
Quick tutorial on associative arrays for other dunces like me:
To generate such an array, try this:
$var = array(
"key1" => "value1",
"key2" => "value2"
);
You can also add individual pairs to an array like so:
$var["key3"] = "value3";
How do you use 'em once they are there?
A. you can call them individually by useing $var[key], or
B. you can use them in loops such as:
foreach ($var as $key => $value) {
echo "Entry $key = $value<br>";
}
http://www.php.net/manual/en/language.variables.php