From:             
Operating system: 
PHP version:      5.4.1
Package:          SimpleXML related
Bug Type:         Bug
Bug description:Array key not casted to Integer.

Description:
------------
PHP Array manual:
"Floats are also cast to integers, which means that the fractional part
will be 
truncated. E.g. the key 8.7 will actually be stored under 8."

But this rule is ignored by SimpleXML object's array.

Test script:
---------------
$xml =
simplexml_load_string("<xml><number>0</number><number>1</number></xml>");

$i = (int) 1;
$d = (float) 1;

$xml->number[$d] = 999;

echo $xml->number[$d] .", ". $xml->number[$i];

Expected result:
----------------
999, 999

Actual result:
--------------
999, 1

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

Reply via email to