ID:          13478
 Comment by:  partage_php at yahoo dot fr
 Reported By: nick at macaw dot demon dot co dot uk
 Status:      Bogus
 Bug Type:    Arrays related
 PHP Version: 4.0.6
 New Comment:

<?

It's a bug !
Look this :

<?
$tbl_1 = array("025" => "hello 025",
               "050" => "hello 050",
               "120" => "hello 120");
                           
$tbl_2 = array("010" => "hello 010",
               "130" => "hello 130");

?>

Gives :

Array ( [025] => hello 025 [050] => hello 050 [0] => hello 120 [010] =>
hello 010 [1] => hello 130 ) 

Why '[1] => hello 130' and not '[130] => hello 130' ?


Previous Comments:
------------------------------------------------------------------------

[2001-09-28 08:28:14] [EMAIL PROTECTED]

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

------------------------------------------------------------------------

[2001-09-28 08:19:02] nick at macaw dot demon dot co dot uk

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

Reply via email to