note 46547 added to language.types.array
| From: | (MarcW) | Date: | Fri, 15 Oct 2004 01:54:32 +0000 |
| Subject: | note 46547 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-78564@lists.php.net to get a copy of this message | ||
It might be worth noting that Maxim Maletsky's comment from 2002 is no longer valid for newer
PHP versions (at least 4.3.4 and 5.0.1):
the following code:
$test[-10] = "-10";
$test[-11] = "-11";
$test[] = "i'm expecting a key value of-9";
var_dump($test);
in fact, prints:
array(3) { [-10]=> string(3) "-10" [-11]=> string(3) "-11" [0]=>
string(22) "i'm expecting a key value of -9" }
I.e. while negative integers are valid as indices, they don't affect the internal counter for
addition of new items, which appears to only be affected by positive integer key values.
Won-kay.
Marc.
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46547
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46547&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46547&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46547&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46547&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46547&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46547&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46547&report=yes
Search -- http://master.php.net/manage/user-notes.php