Re: array sorting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:  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




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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux