#23604 [Opn]: Problem with negative indices
| From: | nicolas at van-lancker dot be | Date: | Tue, 13 May 2003 12:57:21 +0000 |
| Subject: | #23604 [Opn]: Problem with negative indices | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-39519@lists.php.net to get a copy of this message | ||
ID: 23604
User updated by: nicolas at van-lancker dot be
Reported By: nicolas at van-lancker dot be
Status: Open
Bug Type: Arrays related
Operating System: Windows 2000
PHP Version: 4.3.1
New Comment:
This is what the documentation says :
If you omit a key, the maximum of the integer-indices is taken, and
the
new key will be that maximum + 1. As integers can be negative, this is
also true for negative indices. Having e.g. the highest index being -6
will result in -5 being the new key. If no integer-indices exist yet,
the key will be 0 (zero).
My code :
<?php
$arr[-6] = "me";
$arr[] = "you";
?>
"you" is not stored in $arr[-5] but in $arr[0]
$arr[-5] does not exist...
This behaviour is undesired I guess...
Previous Comments:
------------------------------------------------------------------------
[2003-05-13 07:53:04] nicolas at van-lancker dot be
This is what the documentation says :
If you omit a key, the maximum of the integer-indices is taken, and the
new key will be that maximum + 1. As integers can be negative, this is
also true for negative indices. Having e.g. the highest index being -6
will result in -5 being the new key. If no integer-indices exist yet,
the key will be 0 (zero).
My code :
<?php
$arr[-6] = "me";
$arr[] = "you";
?>
"you" is not stored in $arr[-5] but in $arr[0]
$arr[-4] does not exist...
This behaviour is undesired I guess...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23604&edit=1