Doc #62512 [Opn->Csd]: [FR] Error about array operators documentation
Edit report at https://bugs.php.net/bug.php?id=62512&edit=1
ID: 62512
Updated by: yannick@php.net
Reported by: php at maerdo dot com
Summary: [FR] Error about array operators documentation
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Translation problem
Operating System: n/a
PHP Version: 5.4.4
-Assigned To:
+Assigned To: yannick
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
Previous Comments:
------------------------------------------------------------------------
[2012-08-02 09:45:15] yannick@php.net
Automatic comment from SVN on behalf of yannick
Revision: http://svn.php.net/viewvc/?view=revision&revision=326941
Log: Fix bug #62512
------------------------------------------------------------------------
[2012-07-24 05:31:33] googleguy@php.net
The documentation appears to be correct from the English docs. I can't speak for the French
translation, or its accuracy. However, I will note that the addition operator is left-associative
(as
PHP operators take on precedence and associativity rules mostly from C).
So to say that the expression ($arr1 + $arr2) yields left association, is by definition correct.
Because $arr1 will be appending all elements in $arr2, that belong to keys which do not exist in
$arr1.
In your example, the elements of $array1:
(
'a' => 1,
'b' => 2
)
show up first in the resulting array. Any keys found in $array2 that exist in $array1 (in this case
'a'), will simply be ignored and the values of keys found in the second operand, which do
not exist
in the first operand, will be appended in the yielding expression.
This can be a bit confusing when phrased as "left is added to right" or "right is
added to left". So
instead it's best to explain this from the perspective of an operator as opposed to the
perspective
of the operands (in a technical documentation).
A left associative operator tells us that the operands are grouped to the left in the absence of
parenthesis. This means when we spot the operator we need to group its right-hand operand with its
left-hand operand when applying the operator.
I hope this might help to disambiguate the technical wording found in the French translation.
------------------------------------------------------------------------
[2012-07-09 09:58:46] php at maerdo dot com
URL : http://www.php.net/manual/fr/language.operators.array.php
------------------------------------------------------------------------
[2012-07-08 20:38:21] php at maerdo dot com
Description:
------------
This page inform that the addition of two arrays add datas of left array to datas of the right array
:
" L'opérateur + retourne le tableau de droite auquel sont ajoutés les éléments
du tableau de gauche."
After test it, i note the behavior is opposite.
The addition of these arrays result in the addition of datas of the right array to datas of the left
array.
<?php
$array1=['a'=>1,'b'=>2];
$array2=['a'=>'A','B','C'];
var_dump($array1+$array2);
// output
array(4) { ["a"]=> int(1) ["b"]=> int(2) [0]=> string(1) "B"
[1]=> string(1) "C" }
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62512&edit=1
Thread (4 messages)