> -----Original Message-----
> From: Jason Wong [mailto:[EMAIL PROTECTED]
> Sent: 10 March 2003 15:35
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] array question
> 
> 
> On Monday 10 March 2003 21:13, Diana Castillo wrote:
> > If I sort an array, and now the keys are not in numerical 
> order, how can I
> > get the key of the first element?
> > If I do array_shift I get the first element but I want that key.
> 
> Not very elegant -- there must be a better way?
> 
> foreach ($doo as $key => $value) {
>   print "Key:$key Value:$value";  
>   break;
> }

How about

   reset($doo);
   $first_key = key($doo);

?

Cheers!

Mike

---------------------------------------------------------------------
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
Email: [EMAIL PROTECTED]
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