[PHP] Getting key of value added to array with []?

2003-02-04 Thread Leif K-Brooks
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

Re: [PHP] Getting key of value added to array with []?

2003-02-04 Thread 1LT John W. Holmes
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. If elements are only being added with [], then you

Re: [PHP] Getting key of value added to array with []?

2003-02-04 Thread Adam Voigt
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