Re: array_merge_recursive
| From: | Richard Lynch | Date: | Fri, 10 Dec 2004 18:11:45 +0000 |
| Subject: | Re: array_merge_recursive | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-203944@lists.php.net to get a copy of this message | ||
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