php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #34227 Array splice does not document the key renumbering it performs
Submitted: 2005-08-24 07:21 UTC Modified: 2005-08-29 17:35 UTC
From: david dot tulloh at anu dot edu dot au Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2005-08-24 07:21 UTC] david dot tulloh at anu dot edu dot au
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
)



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-29 17:35 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"Note that numeric keys in input are not preserved."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 22:01:33 2025 UTC