#40882 [Asn->Csd]: array_fill with negative start index not documented
ID: 40882
Updated by: vrana@php.net
Reported By: guile_spam at laposte dot net
-Status: Assigned
+Status: Closed
Bug Type: Documentation problem
Operating System: Linux ~~~~ 2.6.12-12mdk #1 F
PHP Version: 5.2.1
Assigned To: nicholsr
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.
Previous Comments:
------------------------------------------------------------------------
[2009-11-23 12:52:01] svn@php.net
Automatic comment from SVN on behalf of vrana
Revision: http://svn.php.net/viewvc/?view=revision&revision=291198
Log: First parameter can't be negative (bug #40882)
------------------------------------------------------------------------
[2008-02-20 15:55:04] nicholsr@php.net
I was about to open the same problem all over again when I found this.
It seems to me that this problem is not really bogus but actually a
documentation problem. array_fill documentation should be changed to
indicate that if the starting index is negative it will be used for the
first entry but subsequent entries start from zero.
Assigning to myself. Not sure when I'll get around to updating the
documentation but its better to have a bug open than not to.
------------------------------------------------------------------------
[2007-03-22 10:25:28] tony2001@php.net
>I guess could have the answer in the bug 24159...
Right, so this is expected.
------------------------------------------------------------------------
[2007-03-21 16:00:30] guile_spam at laposte dot net
Description:
------------
the function "array_fill" doesn't support correctly a negative number
as first parameter.
If start_index is negative, then it starts with the correct value, but
the next key value is always 0.
I guess could have the answer in the bug 24159...
Maybe the documentation have to be updated, or (I hope it will be this
solution) the function array_fill have to fixed :-P
Thx for all!
Reproduce code:
---------------
<?php
print_r(array_fill(-3,5,0));
?>
Expected result:
----------------
Array
(
[-3] => 0
[-2] => 0
[-1] => 0
[0] => 0
[1] => 0
)
Actual result:
--------------
Array
(
[-3] => 0
[0] => 0
[1] => 0
[2] => 0
[3] => 0
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40882&edit=1
Thread (2 messages)