Posted by gosha bine on 05/15/07 14:47
On 15.05.2007 16:07 harvey wrote:
> What is the easiest way to get both the last item name and last item
> value from an associative array?
>
> I can get the value with array_pop() but can't see anything similar
> for the item's name.
>
> Thanks
>
Try
list($key, $val) = each(array_slice($a, -1));
replace 'slice' with 'splice' to remove the last element.
--
gosha bine
extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
[Back to original message]
|