Bug #61877 [PATCH]: Array key not casted to Integer.

From: Date: Fri, 27 Mar 2020 01:04:43 +0000
Subject: Bug #61877 [PATCH]: Array key not casted to Integer.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226278@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61877&edit=1

 ID:                 61877
 Patch added by:     carusogabriel@php.net
 Reported by:        fred dot stcm at gmail dot com
 Summary:            Array key not casted to Integer.
 Status:             Open
 Type:               Bug
 Package:            SimpleXML related
 PHP Version:        5.4.1
 Block user comment: N
 Private report:     N

 New Comment:

The following pull request has been associated:

Patch Name: Fix #61877: Make SimpleXMLElement respect PHP's array rule
On GitHub:  https://github.com/php/php-src/pull/5309
Patch:      https://github.com/php/php-src/pull/5309.patch


Previous Comments:
------------------------------------------------------------------------
[2012-04-30 20:58:00] felipe@php.net

The following patch has been added/updated:

Patch Name: simplexml-patch
Revision:   1335819480
URL:        https://bugs.php.net/patch-display.php?bug=61877&patch=simplexml-patch&revision=1335819480

------------------------------------------------------------------------
[2012-04-30 02:23:42] fred dot stcm at gmail dot com

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 this bug report at https://bugs.php.net/bug.php?id=61877&edit=1


Thread (3 messages)

« previous php.bugs (#226278) next »