Re: array_merge_recursive

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

 



thanks for the help. i do have a question.. say instead of 2 keys in the
array there are 3 or 4.. how would that be done?
i do not know much about arrays so i am trying to learn.

thanks.


----- Original Message ----- 
From: "Craig Slusher" <cslush@xxxxxxxxx>
To: "Sebastian" <sebastian@xxxxxxxxxxxxxxxxxxx>
Cc: <php-general@xxxxxxxxxxxxx>
Sent: Friday, December 10, 2004 2:45 PM
Subject: Re:  array_merge_recursive


> foreach ($animal_counts as $animal => $total) {
>     echo $animal. ':' .$total. '<br>';
> }
>
>
> On Fri, 10 Dec 2004 13:51:36 -0500, Sebastian
> <sebastian@xxxxxxxxxxxxxxxxxxx> wrote:
> > actually, what i mean is i need to get the animal name as well..
> >
> > ie:
> > echo $animal . ' : ' .  $total
> > would output:
> >
> > <animal name> : <total>
> > <animal name> : <total>
> >
> > etc. thanks.
> >
> >
> >
> > ----- Original Message -----
> > From: "Sebastian" <sebastian@xxxxxxxxxxxxxxxxxxx>
> > To: <php-general@xxxxxxxxxxxxx>
> > Sent: Friday, December 10, 2004 12:24 PM
> > Subject:  array_merge_recursive
> >
> > > 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
> > >         )
> > >
> > > )
> > >
> > > the output i need is:
> > > Dogs 5
> > > Cats 9
> > >
> > > I need to add the total but keep just one animal if its already there.
can
> > > someone please help? i been stuck for two days. i appreciate it.
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> > >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> -- 
> Craig Slusher
> Web Programmer
> cslush@xxxxxxxxx
>
>

-- 
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