note 77477 added to function.each

From: Date: Fri, 31 Aug 2007 02:11:47 +0000
Subject: note 77477 added to function.each
Groups: php.notes 
Request: Send a blank email to php-notes+get-129923@lists.php.net to get a copy of this message
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? ---- Server IP: 209.41.74.194 Probable Submitter: 72.82.184.111 ---- Manual Page -- http://www.php.net/manual/en/function.each.php Edit -- https://master.php.net/note/edit/77477 Del: integrated -- https://master.php.net/note/delete/77477/integrated Del: useless -- https://master.php.net/note/delete/77477/useless Del: bad code -- https://master.php.net/note/delete/77477/bad+code Del: spam -- https://master.php.net/note/delete/77477/spam Del: non-english -- https://master.php.net/note/delete/77477/non-english Del: in docs -- https://master.php.net/note/delete/77477/in+docs Del: other reasons-- https://master.php.net/note/delete/77477 Reject -- https://master.php.net/note/reject/77477 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#129923) next »