Re: How to get the key of a specific index of array?
| From: | Burhan Khalid | Date: | Tue, 18 Nov 2003 15:19:52 +0000 |
| Subject: | Re: How to get the key of a specific index of array? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170111@lists.php.net to get a copy of this message | ||
PhiSYS wrote:
How to get the key of a specific index of array?Sorry, but an index is they key. $foo = array(0 => "Apples", 1 => "Oranges", 2 => "Grapes"); $key = 2; $value = $foo[$key]; echo $value; //you would get Grapes //another way (maybe this is what you are after) while(list($key,$value) = each($foo)) { echo "For key ".$key." the value is ".$value; } -- Burhan Khalid phplist[at]meidomus[dot]com http://www.meidomus.com ----------------------- "Documentation is like sex: when it is good, it is very, very good; and when it is bad, it is better than nothing."