#34227 [NEW]: Array splice does not document the key renumbering it performs
| From: | david dot tulloh at anu dot edu dot au | Date: | Wed, 24 Aug 2005 05:21:41 +0000 |
| Subject: | #34227 [NEW]: Array splice does not document the key renumbering it performs | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969369694@lists.php.net to get a copy of this message | ||
From: david dot tulloh at anu dot edu dot au
Operating system:
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: Array splice does not document the key renumbering it performs
Description:
------------
The array_splice documentation doesn't warn about the fact that
array_splice will change the keys of the original array. This occurs
whenever the spliced in array and removed array are of a different size.
For example in the code below you can see that the key for 'f' has been
changed by the array_splice operation.
Reproduce code:
---------------
$a = array('a', 'b', 'c', 'd', 'e',
'f');
Array
(
[0] => a
[1] => b
[2] => c
[3] => d
[4] => e
[5] => f
)
array_splice($a, 2, 2, array('g', 'h', 'i'));
Array
(
[0] => a
[1] => b
[2] => g
[3] => h
[4] => i
[5] => e
[6] => f
)
--
Edit bug report at http://bugs.php.net/?id=34227&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34227&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34227&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34227&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34227&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34227&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34227&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34227&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34227&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34227&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34227&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=34227&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=34227&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34227&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34227&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34227&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34227&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34227&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34227&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34227&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34227&r=mysqlcfg