Date: 09/28/01
- Next message: Zeev Suraski: "[PHP-DEV] RC3"
- Previous message: eugene <email protected>: "[PHP-DEV] Bug #13486: Apache/PHP hangs"
- In reply to: Nick Lindridge: "[PHP-DEV] Re: Array merge changes VALUE of keys, never mind the type"
- Next in thread: Steve Meyers: "[PHP-DEV] Re: Array merge changes VALUE of keys, never mind the type"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 28 Sep 2001, Nick Lindridge wrote:
> > array_merge() does *not* change the value of keys. Period.
>
> Sigh, yes it does. And below is the simple proof.
I should have said, does not change the type of keys.
> <? // -*- c -*-
>
> $arr1 = array(1=>'one');
> $arr2 = array(2=>'two');
>
> print_r(array_merge($arr1, $arr2));
>
> ?>
>
> gives:
>
> Array ( [0] => one [1] => two )
>
> Please tell me in what way this hasn't changed the
> keys.
Yes, array_merge() is meant to simply concatenate two arrays together,
one after the other, so it _has_ to renumber the numeric keys. To do
what you want, use the + operator on the arrays.
> Derrick and your response andrei are very
> disappointing.
I guess you just have to live with it.
-Andrei
As I was going up the stair, I met a man who wasn't there.
He wasn't there again today. I wish, I wish he'd stay away.
-Hughes Mearns
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Zeev Suraski: "[PHP-DEV] RC3"
- Previous message: eugene <email protected>: "[PHP-DEV] Bug #13486: Apache/PHP hangs"
- In reply to: Nick Lindridge: "[PHP-DEV] Re: Array merge changes VALUE of keys, never mind the type"
- Next in thread: Steve Meyers: "[PHP-DEV] Re: Array merge changes VALUE of keys, never mind the type"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

