#23604 [NEW]: Problem with negative indices

From: Date: Tue, 13 May 2003 12:53:05 +0000
Subject: #23604 [NEW]: Problem with negative indices
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-39518@lists.php.net to get a copy of this message
From:             nicolas at van-lancker dot be
Operating system: Windows 2000
PHP version:      4.3.1
PHP Bug Type:     Arrays related
Bug description:  Problem with negative indices

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 bug report at http://bugs.php.net/?id=23604&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=23604&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=23604&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=23604&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=23604&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=23604&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=23604&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=23604&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=23604&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=23604&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=23604&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23604&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=23604&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=23604&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=23604&r=gnused



Thread (5 messages)

« previous php.bugs (#39518) next »