Re: [PHP] Highest Key in an Array

2004-09-17 Thread Martin Holm
Daniel Schierbeck wrote:
I've been looking at php.net, but i couldn't find what i'm searching 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


Re: [PHP] Highest Key in an Array

2004-09-17 Thread John Nichel
Daniel Schierbeck wrote:
I've been looking at php.net, but i couldn't find what i'm searching 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
Sort the array, then use end().
http://us4.php.net/array
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Highest Key in an Array

2004-09-17 Thread John Nichel
Martin Holm wrote:
Daniel Schierbeck wrote:
I've been looking at php.net, but i couldn't find what i'm searching 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);
Oops, he wanted the key.  Martin's right.  My suggestion would have 
given you the value, not the key.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Highest Key in an Array

2004-09-17 Thread Gryffyn, Trevor
Or...

$highestkey = max(array_keys($arr));

 -Original Message-
 From: Martin Holm [mailto:[EMAIL PROTECTED] 
 Sent: Friday, September 17, 2004 11:11 AM
 To: Daniel Schierbeck
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] Highest Key in an Array
 
 
 Daniel Schierbeck wrote:
 
  I've been looking at php.net, but i couldn't find what i'm 
 searching 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
 
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Highest Key in an Array

2004-09-17 Thread Daniel Schierbeck
Trevor Gryffyn wrote:
Or...
$highestkey = max(array_keys($arr));

-Original Message-
From: Martin Holm [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 17, 2004 11:11 AM
To: Daniel Schierbeck
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Highest Key in an Array

Daniel Schierbeck wrote:

I've been looking at php.net, but i couldn't find what i'm 
searching 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

Damn you're fast!
Thanks guys, it's all yubbely-dubbely now!
Daniel Schierbeck
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Highest Key in an Array

2004-09-17 Thread Daniel Schierbeck
I'm using it for the Wiki (thanks for that as well guys):
http://aoide.1go.dk/lab/compare.php5
Source: http://aoide.1go.dk/lab/compare.source.php5
(it's just a test)
Daniel Schierbeck
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php