[nycphp-talk] highest key of an array
Adam Maccabee Trachtenberg
adam at trachtenberg.com
Mon Sep 19 17:19:48 EDT 2005
On Mon, 19 Sep 2005, Odra Gola wrote:
> is there a quick way to return the numerically highest key of an array? (not
> the element)
> I wrote my own function to do it, but I'm affraid I'm reinventing the wheel
Assuming you add keys in a sensible order:
end($array);
$highest = key($array);
Otherwise, you should sort the array first.
-adam
--
adam at trachtenberg.com | http://www.trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!
More information about the talk
mailing list