> -----Original Message-----
> From: PHP List [mailto:php_list@;ibcnetwork.net]
> Sent: 29 October 2002 17:20
> To: php
> Subject: Re: [PHP] Array Question
> No, array_keys does not do what I want, in order to user 
> array_keys, it
> assumes I know the value of the key, but I don't,

Er -- no.  Go read its definition again -- you *may* pass it a value for which you 
want the corresponding keys, but by omitting the value argument you may also ask for 
*all* of the keys of your array.

>  I want to 
> get the value of
> the key but all I know is the index.

First of all, I presume this means that, for example, if $index==4, you want to know 
what the key of the 4th array element is?

In that case, the following, whilst not ideal, may be your best solution:

   $keys = array_keys($array);
   $required_key = $keys[$index];



Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to