Doc #79402 [NoF->Opn]: Description fix suggestion
[email protected] Tue, 14 Dec 2021 10:29:34 +0000
| Newsgroups | php.doc.bugs |
|---|---|
| Message-ID | <[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=79402&edit=1 ID: 79402 Updated by: [email protected] Reported by: simongcc at gmail dot com Summary: Description fix suggestion -Status: No Feedback +Status: Open Type: Documentation Problem -Package: Documentation problem +Package: *General Issues PHP Version: Irrelevant -Assigned To: cmb +Assigned To: Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2021-12-14 01:29:43] simongcc at gmail dot com The description describe correctly, however, using "union of" in the example have a potential to mislead some "fast glance" people. But I agree, it is a minor problem instead of critical. ------------------------------------------------------------------------ [2020-04-05 04:22:08] php-bugs at lists dot php dot net No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. ------------------------------------------------------------------------ [2020-03-22 13:37:08] [email protected] Isn't that already sufficiently explained: | The + operator returns the right-hand array appended to the | left-hand array; for keys that exist in both arrays, the elements | from the left-hand array will be used, and the matching elements | from the right-hand array will be ignored. ------------------------------------------------------------------------ [2020-03-22 00:40:32] simongcc at gmail dot com Description: ------------ --- From manual page: https://php.net/language.operators.array --- It is only a problem in description. In the docs, it states that $a + $b is Union and it is Union of $a and $b. But it is not completely reflecting the characteristic of the Union in PHP. Since strictly speaking, an Union should be mutually inclusive of different things. In PHP, it is only an union of key regardless of value. So it should be written as Union of the key in $a and $b and based on $a or vice versa if it is $b + $a. (Because when there is/are key(s) exist(s) in the first variable, the same key(s) in the second variable will be ignored) Test script: --------------- $a = array('something' => 'interesting', 2); $b = array('another' => 'interesting thing', 0 => 3); $c = $a + $b; $d = $b + $a; print_r($c); print_r($d); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79402&edit=1