From:             anton at zebooka dot com
Operating system: Ubuntu 9.10
PHP version:      5.2.11
PHP Bug Type:     Arrays related
Bug description:  Numerical keys casted as strings in arrays, when converting 
from object

Description:
------------
As mentioned in documentation, array items can have either string or int.
However keys that are numerical strings are converted to int.

This is how to create an array with item, which key is string, while it is
a number.

Reproduce code:
---------------
$a = array(123);
$o = (object) $a;
$o->{0} = 456;
$a = (array) $o;
var_dump($a);

Expected result:
----------------
array(2) {
  [0]=>
  int(456)
}

Actual result:
--------------
array(2) {
  [0]=>
  int(123)
  ["0"]=>
  int(456)
}

-- 
Edit bug report at http://bugs.php.net/?id=50423&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=50423&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=50423&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=50423&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=50423&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=50423&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=50423&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=50423&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=50423&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=50423&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=50423&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=50423&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=50423&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=50423&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=50423&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=50423&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=50423&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=50423&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=50423&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=50423&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=50423&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=50423&r=mysqlcfg

Reply via email to