Re: Getting key of value added to array with []?
| From: | Adam Voigt | Date: | Tue, 04 Feb 2003 13:44:27 +0000 |
| Subject: | Re: Getting key of value added to array with []? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-134259@lists.php.net to get a copy of this message | ||
foreach($counter = 0; $counter < 10; $counter++)
{
$array[] = $counter;
}
$lastkey = (count($array)-1);
On Tue, 2003-02-04 at 06:43, Leif K-Brooks wrote:
Is there any way to get the key of an element added to an array with
[]?
I need to use this for a reference to it. The only idea I can
think of
is to foreach through the array and use the last key looped through,
but
that seems very dirty.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Adam Voigt (adam@cryptocomm.com)
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc
Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc
Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc