Inconsistency in Array section of manual
| From: | keith dot underdown at qconsultancy dot co dot uk | Date: | Fri, 28 Feb 2003 14:30:12 +0000 |
| Subject: | Inconsistency in Array section of manual | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969352005@lists.php.net to get a copy of this message | ||
www.php.net/manual/en/language.types.array.php is inconsistent on the issue
of integer keys for arrays.
Right at the start we have:
------------------------------------
array( [key =>] value
, ...
)
// key is either string or nonnegative integer
// value can be anything
-------------------------------------
which to my mind rules out negative integers as keys. as someone well versed
in traditional arrays that sees reasonable!
However, later we have:
--------------------------------------------
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). If you specify a key that already has a value assigned to it, that
value will be overwritten.
-----------------------------------------------
which implies that negative integers are ok as a key!
Which is correct?
______________________________________
Keith Underdown
Q Consultancy
8A New Rowley Rd
DUDLEY
DY2 8AS
+44 1384 231180
+44 7798 934782