|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #79402 Description fix suggestion
Submitted: 2020-03-22 00:40 UTC Modified: 2021-12-14 10:29 UTC
From: simongcc at gmail dot com Assigned:
Status: Open Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: simongcc at gmail dot com
New email:
PHP Version: OS:


 [2020-03-22 00:40 UTC] simongcc at gmail dot com
From manual page:

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;



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-22 13:37 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-03-22 13:37 UTC]
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-04-05 04:22 UTC] 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.
 [2021-12-14 01:29 UTC] 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.
 [2021-12-14 10:29 UTC]
-Status: No Feedback +Status: Open -Package: Documentation problem +Package: *General Issues -Assigned To: cmb +Assigned To:
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 28 16:01:33 2024 UTC