Re: Inconsistency in Array section of manual

From: Date: Fri, 28 Feb 2003 17:23:00 +0000
Subject: Re: Inconsistency in Array section of manual
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969352010@lists.php.net to get a copy of this message
Please submit "Documentation problems" at http://bugs.php.net/ Thanks, Goba keith.underdown@qconsultancy.co.uk wrote:
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


« previous php.doc (#969352010) next »