Sebastian wrote:
> Hi.
>
> I am using this array_merge_recursive to merge two arrays, the array looks
> like this:
>
> Array
> (
>     [0] => Array
>         (
>             [animal] => Dogs
>             [total] => 5
>
>         )
>
>     [1] => Array
>         (
>             [animal] => Cats
>             [total] => 3
>         )
>
>     [2] => Array
>         (
>             [animal] => Cats
>             [total] => 6
>         )
>
> )

$animals = array(array('animal'=>'Dogs', 'total'=>5),
array('animal'=>'Cats', 'total'=>3), array('animal'=>'Cats','total'=>6));

$animal_counts = array();
while (list(, $animal_total) = each($animals)){
  $animal = $animal_total['animal'];
  $total = $animal_total['total'];
  $animal_counts[$animal] += $total;
}

-- 
Like Music?
http://l-i-e.com/artists.htm

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

Reply via email to