Leif K-Brooks schrieb: > 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. >
$foo[]='bar'; will insert 'bar' as the last item of the array $foo. To get this you might use $erg = key($foo); // the key of the current element or $erg = pos($foo); // the value of the current element maybe if something happend between the insertion first head to the last item $erg = end($foo); // get the last element of array $foo instead of foreach you can also use array_walk($arr, 'func'); -- @ Goetz Lohmann, Germany | Web-Developer & Sys-Admin \/ ------------------------------------------------------ () He's the fellow that people wonder what he does and || why the company needs him, until he goes on vacation. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php