Re: Merging arrays...
| From: | Jerry | Date: | Tue, 25 Jul 2000 22:14:01 +0000 |
| Subject: | Re: Merging arrays... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-8153@lists.php.net to get a copy of this message | ||
try something like this
foreach(array1 as $key => $value) array2[$key]+=$value;
Jerry Verhoef
http://php.start4all.com
----- Original Message -----
From: "Wachaca" <wachaca@santiago.cl>
To: <php-general@lists.php.net>
Sent: Wednesday, July 26, 2000 12:06 AM
Subject: [PHP] Merging arrays...
Hello,
I have 2 arrays, which are results from 2 different SQL commands.
I was wondering how I could "merge" these 2 into one.
The arrays have one field which I would like to add.
For example
array1 would have
user1 4
user2 3
array2 would have
user1 7
user3 9
So the final array which I want to create would have
user1 11
user3 9
user2 3
The new array would be sorted by size of field 2.
Thanks,
WIT
PS. Please reply to my email address since I cannot handle the volume on
this mailing list.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net