Re: array sorting
| From: | Ignatius Reilly | Date: | Tue, 12 Nov 2002 12:53:56 +0000 |
| Subject: | Re: array sorting | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-23232@lists.php.net to get a copy of this message | ||
Just loop through the first index, then search on the second index:
while ( list( $key, $value ) = each( $my_arr ) ) {
// now $value is your ( [0] => 10 [1] => 40 [2] => 50 [3] => 80 [4] =>
130 [5] => 220 [6] => 320 ) array
// sort your array by values
sort( $value ) ;
// get the last value
$last_value = array_pop( $value ) ;
// do something with this value...
}
But it seems to me there still misses a link between your two series of data
(years, values)
So try to get an array where keys are years, not numerical indexes?
HTH
Ignatius
____________________________________________
----- Original Message -----
From: "Martin Allan Jensen" <bailey@sprit.dk>
To: <php-db@lists.php.net>
Sent: Tuesday, November 12, 2002 1:37 PM
Subject: [PHP-DB] array sorting
Hi everyone...
I got a bit longer now......
But i have some trouble sorting my arrays....
I get this array returned.
Array ( [0] => Array ( [0] => 10 [1] => 40 [2] => 50 [3] => 80 [4] => 130
[5] => 220 [6] => 320 ) [1] => Array ( [0] => 10 [1] => 40 [2] => 50 [3] =>
80 [4] => 130 [5] => 220 [6] => 320 [7] => 440 [8] => 570 ) [2] => )
I ain't good at it, but i guess this is a two dimesioned array...
The question is now, i need to get the highest values of each "sub" array
witch would be 320 & 570 in THIS CASE ??
Thanks so much!!
Martin Allan Jensen
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php