Re: [PHP-DEV] Bug #13478 Updated: array_merge changes keys From: Markus Fischer (mfischer <email protected>)
Date: 09/28/01

What a nasty 'feature'. Can't we get rid of it ASAP?

It would allow comfty hash non-alpha key/value
inserting(reassembling)

- Markus

On Fri, Sep 28, 2001 at 12:28:15PM -0000, derick <email protected> wrote :
> ID: 13478
> Updated by: derick
> Reported By: nick <email protected>
> Old Status: Open
> Status: Bogus
> Bug Type: Arrays related
> Operating System:
> PHP Version: 4.0.6
> New Comment:
>
> This is not a bug, but a feature. All string indexes are converted to numbers if possible, even like this:
> <?php
> $a = array ('4' => "test");
> print_r ($a);
> ?>
>
> will show:
>
> Array
> (
> [4] => test
> )
>
> Making it bogus
>
> Previous Comments:
> ------------------------------------------------------------------------
>
> [2001-09-28 08:19:02] nick <email protected>
>
> Found in 4.0.7RC2 but probably present before. Array merge changes keys that are string-numeric. e.g.
>
> <?
> $arr1 = array('1'=>'one', '2'=>'two');
> $arr2 = array('a'=>'all');
>
> print_r(array_merge($arr1, $arr2));
> ?>
>
> gives:
>
> Array ( [0] => one [1] => two [a] => all )
>
> A workaround kludge is to prefix string-numeric keys with a letter.
>
>
> ------------------------------------------------------------------------
>
>
>
> Edit this bug report at http://bugs.php.net/?id=13478&edit=1
>
>
> --
> 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>

-- 
Markus Fischer,  http://guru.josefine.at/~mfischer/
EMail:         mfischer <email protected>
PGP Public  Key: http://guru.josefine.at/~mfischer/C2272BD0.asc
PGP Fingerprint: D3B0 DD4F E12B F911 3CE1  C2B5 D674 B445 C227 2BD0
              -All your scripts are belong to Zend-

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