Bug #15520 Updated: array_slice destroys numeric keys
| From: | eru@php.net | Date: | Thu, 04 Jul 2002 00:06:41 +0000 |
| Subject: | Bug #15520 Updated: array_slice destroys numeric keys | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-13052@lists.php.net to get a copy of this message | ||
ID: 15520
Updated by: eru@php.net
Reported By: david@acz.org
-Status: Open
+Status: Bogus
Bug Type: Arrays related
Operating System: Debian sid
PHP Version: 4.1.1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
From the manual-page:
Note that array_slice() will ignore array keys, and will calculate
offsets and lengths based on the actual positions of elements within
the array.
Previous Comments:
------------------------------------------------------------------------
[2002-02-12 08:59:34] david@acz.org
The array_slice function destroys keys that are numeric (even if used
as strings), but not string keys. This is a serious bug, which makes
the function unusable. I had to write my own function to correctly
take the slice of an array. If this is indeed intended behavior, then
it should be noted as such in the manual, and a new function added to
take array slices that does not destroy numeric keys.
<?
$a = array("7" => "foo", "f" => "bar",
"13" => "blah");
print_r($a);
print_r(array_slice($a, 0));
?>
Array
(
[7] => foo
[f] => bar
[13] => blah
)
Array
(
[0] => foo
[f] => bar
[1] => blah
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=15520&edit=1