note 77477 deleted from function.each by nicobn
| From: | nicobn@php.net | Date: | Fri, 18 Feb 2011 16:05:25 +0000 |
| Subject: | note 77477 deleted from function.each by nicobn | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177118@lists.php.net to get a copy of this message | ||
Note Submitter: Mark Rosenberg
----
manz_2007 at yahoo dot com:
You don't seem to understand what a key is. It is the unique key which references the item in
the array. It can't be duplicated. To make it more clear:
array[0]="hello";
array[0]="world";
print(array[0]);
array[0] will obviously print "world". This is because you first set the array element
with the key 0 to hello, and then set it to world. The old value is overwritten.
In your example hire_date is a key, just like 0 is. You set the value of it twice, and of course the
second value overwrites the first.
You can of course enter duplicate values into an array, but not keys. Think about it, how would you
reference two different values with one key?