mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Document the changed array indexing, pending information from the dev
team on what it's really supposed to be doing. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@133462 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
2f9280c037
commit
66da45a2bd
1 changed files with 29 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.122 $ -->
|
||||
<!-- $Revision: 1.123 $ -->
|
||||
<chapter id="language.types">
|
||||
<title>Types</title>
|
||||
|
||||
|
@ -1317,12 +1317,8 @@ echo $arr["somearray"]["a"]; // 42
|
|||
<para>
|
||||
If you do not specify a key for a given value, then the maximum
|
||||
of the integer indices is taken, and the new key will be that
|
||||
maximum value + 1--unless that maximum value is negative (is it
|
||||
perfectly legal to have negative array indices). In this case,
|
||||
the new key will be <literal>0</literal>. If no integer indices
|
||||
exist yet, the key will be <literal>0</literal> (zero). If you
|
||||
specify a key that already has a value assigned to it, that
|
||||
value will be overwritten.
|
||||
maximum value + 1. If you specify a key that already has a value
|
||||
assigned to it, that value will be overwritten.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
|
@ -1337,6 +1333,16 @@ array(5 => 43, 6 => 32, 7 => 56, "b" => 12);
|
|||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
<warning>
|
||||
<simpara>
|
||||
As of PHP 4.3.0, the index generation behaviour described
|
||||
above has changed. Now, if you append to an array in which
|
||||
the current maximum key is negative, then the next key
|
||||
created will be zero (<literal>0</literal>). Before, the new
|
||||
index would have been set to the largest existing key + 1,
|
||||
the same as positive indices are.
|
||||
</simpara>
|
||||
</warning>
|
||||
<para>
|
||||
Using &true; as a key will evaluate to <type>integer</type>
|
||||
<literal>1</literal> as key. Using &false; as a key will evaluate
|
||||
|
@ -1397,13 +1403,22 @@ unset($arr); // This deletes the whole array
|
|||
<para>
|
||||
As mentioned above, if you provide the brackets with no key
|
||||
specified, then the maximum of the existing integer indices is
|
||||
taken, and the new key will be that maximum value + 1--unless
|
||||
that maximum value is negative (is it perfectly legal to have
|
||||
negative array indices). In this case, the new key will be
|
||||
<literal>0</literal>. If no integer indices exist yet, the key
|
||||
will be <literal>0</literal> (zero). If you specify a key that
|
||||
already has a value assigned to it, that value will be
|
||||
overwritten.
|
||||
taken, and the new key will be that maximum value + 1 . If no
|
||||
integer indices exist yet, the key will be <literal>0</literal>
|
||||
(zero). If you specify a key that already has a value assigned
|
||||
to it, that value will be overwritten.
|
||||
</para>
|
||||
<para>
|
||||
<warning>
|
||||
<simpara>
|
||||
As of PHP 4.3.0, the index generation behaviour described
|
||||
above has changed. Now, if you append to an array in which
|
||||
the current maximum key is negative, then the next key
|
||||
created will be zero (<literal>0</literal>). Before, the new
|
||||
index would have been set to the largest existing key + 1,
|
||||
the same as positive indices are.
|
||||
</simpara>
|
||||
</warning>
|
||||
</para>
|
||||
<para>
|
||||
Note that the maximum integer key used for this <emphasis>need
|
||||
|
|
Loading…
Reference in a new issue