[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-doc-bugs
Subject:    [DOC-BUGS] [PHP-BUG] Doc #51699 [NEW]: array_merge() reindexes multiple arrays - doc error
From:       "stevenrusch at gmail dot com"<php-bugs () lists ! php ! net>
Date:       2010-04-29 23:41:40
Message-ID: bug-51699 () bugs ! php ! net
[Download RAW message or body]

From:             
Operating system: WinXp
PHP version:      Irrelevant
Package:          Documentation problem
Bug Type:         Documentation Problem
Bug description:array_merge() reindexes multiple arrays - doc error

Description:
------------
The 3rd paragraph of documentation description states:
"If only one array is given and the array is numerically indexed, the keys
get reindexed in a continuous way."

The "If only one array is given" is incorrect. I supplied two arrays, both
numerically indexed, and the result was reindexed (as also shown in
Example#3). The sentence implies this would not happen if multiple
numerically indexed arrays were given because it says "if only one...". The
documentation should state: "If one or more arrays are given in which all
arrays contain only numeric keys, the array values are merged and the keys
are reindexed starting with zero in a continuous way." or something to that
effect.

I realize Example #3 somewhat shows this by supplying two arrays one of
which is empty and it shows the reindex. It would still be nice if the
wording in the description above matched this. As you guessed, I read the
doc description, used it, debugged my problem, and THEN noticed Example #3.

Test script:
---------------
$array1 = array(10=>'Ten',11=>'eleven');
$array2 = array(5=>'five',16=>'sixteen');
var_dump(array_merge($array1,$array2));


Expected result:
----------------
array(4) { [10]=>  string(3) "Ten" 
           [11]=>  string(6) "eleven" 
           [5]=>  string(4) "five" 
           [16]=>  string(7) "sixteen" } 

Actual result:
--------------
array(4) { [0]=>  string(3) "Ten" 
           [1]=>  string(6) "eleven" 
           [2]=>  string(4) "five" 
           [3]=>  string(7) "sixteen" } 

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51699&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=51699&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=51699&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=51699&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=51699&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51699&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=51699&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=51699&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=51699&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=51699&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=51699&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=51699&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=51699&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=51699&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=51699&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51699&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51699&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=51699&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=51699&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=51699&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=51699&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=51699&r=mysqlcfg


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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic