Doc #80295 [NEW]: + operator on arrays is documented as Union but it's not
From: rimas at kudelis dot lt
Operating system:
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:+ operator on arrays is documented as Union but it's not
Description:
------------
The documentation for array operators currently says this:
> $a + $b Union Union of $a and $b.
At least to me, this signals that if I apply this operator on two arrays
(e.g. [1, 2] and [3, 4, 5, 6]), I would get an array which holds all
elements appearing in each array: [1, 2, 3, 4, 5, 6]. But that's not
what I get. Instead, I get [1, 2, 5, 6], as documented in a note below
the initial table:
> 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.
as well as in a set of examples below.
I believe it's wrong to refer to this operation as simply union, thus I
suggest to change the documentation to make it more obvious upfront.
I don't have a good idea how to reword it exactly ATM, but perhaps just
changing "Union" to "Union by keys" in the table would be enough?
--
Edit bug report at https://bugs.php.net/bug.php?id=80295&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80295&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80295&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80295&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80295&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80295&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80295&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80295&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80295&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80295&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80295&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80295&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80295&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80295&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80295&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80295&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80295&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80295&r=mysqlcfg
Thread (3 messages)
- rimas at kudelis dot lt