From:             [EMAIL PROTECTED]
Operating system: Linux
PHP version:      4.3.0
PHP Bug Type:     Arrays related
Bug description:  strange behaviour of mixed type in array-keys

<?php

$a = array(-1=>1,
           '-1'=>2,
           0=>3,
           '0'=>4,
           1=>5,
           '1'=>6
           );

print_r($a);

?>

produces:
Array
(
    [-1] => 1
    [-1] => 2
    [0] => 4
    [1] => 6
)


foreach (array_keys($a) as $key) echo $key, ': ', gettype($key), "\n";
produces:
-1: integer
-1: string
0: integer
1: integer

so it seems strings containing negative integers do not get converted to
integers automagically but positive integers are.


-- 
Edit bug report at http://bugs.php.net/?id=21918&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=21918&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=21918&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=21918&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=21918&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=21918&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=21918&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=21918&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=21918&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=21918&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=21918&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21918&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=21918&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=21918&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=21918&r=gnused

Reply via email to