> -----Original Message-----
> From: John Wulff [mailto:[EMAIL PROTECTED]
> Sent: 02 July 2003 21:26
> 
> Sorry for the multiple post!! Apparently when pasting I hit 
> some magic send
> key.I'd like to calculate the largest member of this array 
> without taking
> into
> account the first value which is obvisouly not numeric.
> 
> So far this is how I'm doing it, but sometimes I get returned 
> a month for
> the max.
> 
> $high = end(array_reduce($cdata,
>   create_function('$a, $b',
>   'return array(max(array_reduce($a, "max"),
>   array_reduce($b, "max")));')));
> 
> Array
> (
>     [0] => Array
>         (
>             [0] => Jan-99
>             [1] => 6399.36
>             [2] => 6132.71
>             [3] => 2242.20
>             [4] => 53.27
>             [5] => 87.34
>         )
> 
>     [1] => Array
>         (
>             [0] => Feb-99
>             [1] => 5754.72
>             [2] => 3964.93
>             [3] => 6145.98
>             [4] => 693.32
>             [5] => 23.80
>         )
> )

Would this do?

    $high = NULL;
    foreach ($cdata as $month):
        $a_high = max(array_slice($month, 1));
        $high = is_null($high) ? $a_high : max($high, $a_high);
    endforeach;

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

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

Reply via email to