ID: 15520 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Verified +Status: Open Bug Type: Feature/Change Request Operating System: Linux PHP Version: 4.3.0-dev
Previous Comments: ------------------------------------------------------------------------ [2002-07-03 21:16:38] [EMAIL PROTECTED] Got me convinced: re-categorizing, -versioning, etc. ------------------------------------------------------------------------ [2002-07-03 20:29:07] [EMAIL PROTECTED] This is a bug. Or at least, it is a very serious documentation problem. The function is taking the slices correctly. But it is destroying numeric keys, and leaving non-numeric keys alone. Why does it arbitrarily change keys that happen to be numeric? Array keys are not based on numbers, so array_slice should not be concerned with their actual value, especially if it is using the actual element positions to calculate the slice. ------------------------------------------------------------------------ [2002-07-03 20:06:40] [EMAIL PROTECTED] 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. ------------------------------------------------------------------------ [2002-02-12 08:59:34] [EMAIL PROTECTED] 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