Re: Highest Key in an Array
| From: | Daniel Schierbeck | Date: | Fri, 17 Sep 2004 15:30:50 +0000 |
| Subject: | Re: Highest Key in an Array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-196964@lists.php.net to get a copy of this message | ||
Trevor Gryffyn wrote:
Or... $highestkey = max(array_keys($arr));Thanks guys, it's all yubbely-dubbely now! Daniel Schierbeck-----Original Message----- From: Martin Holm [mailto:martin.holm@drutt.com] Sent: Friday, September 17, 2004 11:11 AM To: Daniel Schierbeck Cc: php-general@lists.php.net Subject: Re: [PHP] Highest Key in an Array Daniel Schierbeck wrote:Damn you're fast!I've been looking at php.net, but i couldn't find what i'msearching for.I have a numeric array, and i'd like to get the highest key. E.g. $arr = array(3 => "foo", 7 => "bar", 43 => "foobar"); What i want is a function that, in this case, returns 43. Daniel Schierbeck$arr = array(3 => "foo", 7 => "bar", 43 => "foobar"); krsort($arr); $highestkey = key($arr); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php