note 77477 deleted from function.each by nicobn

[email protected] Fri, 18 Feb 2011 08:05:25 -0800
Newsgroups php.notes
Message-ID <[email protected]>
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?