For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > August 2005 > #34227 [Opn->Csd]: Array splice does not document the key renumbering it performs









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #34227 [Opn->Csd]: Array splice does not document the key renumbering it performs
vrana@php.net

2005-08-29, 6:56 pm

ID: 34227
Updated by: vrana@php.net
Reported By: david dot tulloh at anu dot edu dot au
-Status: Open
+Status: Closed
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:

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."


Previous Comments:
------------------------------------------------------------------------

[2005-08-24 07:21:41] 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
)




------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=34227&edit=1
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com