Re: Calculating Largest Member of Array

From: Date: Thu, 03 Jul 2003 13:43:03 +0000
Subject: Re: Calculating Largest Member of Array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-153878@lists.php.net to get a copy of this message
why not just change your array structure a little so that the date is the key, and the elements are the values. so it would look like this. Array ( [Jan-99] => Array ( [0] => 6399.36 [1] => 6132.71 [2] => 2242.20 [3] => 53.27 [4] => 87.34 ) [Feb-99] => Array ( [0] => 5754.72 [1] => 3964.93 [2] => 6145.98 [3] => 693.32 [4] => 23.80 ) ) That would make it much easier. I think. - Anthony "John Wulff" <johnw@orcasnet.com> wrote in message news:20030702202704.38706.qmail@pb1.pair.com... > 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 > ) > ) > > >

« previous php.general (#153878) next »