Re: array_merge_recursive

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

 






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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux