#21918 [Ver->Csd]: strange behaviour of mixed type in array-keys
| From: | helly@php.net | Date: | Mon, 11 Aug 2003 20:15:36 +0000 |
| Subject: | #21918 [Ver->Csd]: strange behaviour of mixed type in array-keys | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-45758@lists.php.net to get a copy of this message | ||
ID: 21918
Updated by: helly@php.net
Reported By: messju at lammfellpuschen dot de
-Status: Verified
+Status: Closed
Bug Type: Scripting Engine problem
-Operating System: Linux
+Operating System: *
-PHP Version: 4.3.0/5.0.0
+PHP Version: 4.3.3-RC3/5.0.0b2
Assigned To: helly
New Comment:
This bug has been fixed in CVS.
In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2003-02-08 12:35:57] moriyoshi@php.net
Related to bug #8325
------------------------------------------------------------------------
[2003-01-29 02:22:57] messju at lammfellpuschen dot de
I relied on http://www.php.net/manual/en/language.types.array.php
it states:
"A key is either an integer or a string. If a key is the standard
representation of an integer, it will be interpreted as such (i.e. "8"
will be interpreted as 8, while "08" will be interpreted as "08")."
so the keys should be casted to int, or it is a documentation-bug, or
"-1" is not a "standard representation of an integer".
------------------------------------------------------------------------
[2003-01-29 00:57:01] sniper@php.net
<?php
$a = array(
'-1' => '-1',
'0' => '0',
'1' => '1',
);
var_dump($a);
?>
Output:
array(3) {
["-1"]=>
string(2) "-1"
[0]=>
string(1) "0"
[1]=>
string(1) "1"
}
(the '0' and '1' indexes are converted to integers..)
Not sure if this is actually expected behaviour. :)
------------------------------------------------------------------------
[2003-01-29 00:39:34] nicos@php.net
The bug can be that it shouldn't cast positive numbers to string and
not that it should cast negative numbers to string.
------------------------------------------------------------------------
[2003-01-29 00:31:41] nicos@php.net
Verified under PHP 4.3.0 with Zend Engine v1.3.0 and PHP 5.0.0-dev with
Zend Engine v2.0.0-dev.
It looks like '-1' isn't casted to int as it should.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/21918
--
Edit this bug report at http://bugs.php.net/?id=21918&edit=1