While translating the Portuguese manual, I catch this.

diff -r1.115 -r1.116 types.xml
<       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 <literal>-6</literal> will result in <literal>-5</literal>
being
<       the new key. 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.
---
>       If you provide the brackets without specifying a key, 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.

Is a copy&past problem or the behavior change?

My machine: Win2K PHP 4.2.1 CGI

<?
$arr[-5] = "minus five";
$arr[] = "minus four";

var_dump($arr);
?>

outputs:
array(2) {
  [-5]=>
  string(10) "minus five"
  [-4]=>
  string(10) "minus four"
}

[]s

André Æ


-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to