PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #40882 array_fill with negative start index not documented
Submitted:21 Mar 2007 4:00pm UTC Modified: 23 Nov 12:52pm UTC
From:guile_spam at laposte dot net Assigned to:nicholsr
Status:Closed Category:Documentation problem
Version:5.2.1 OS:Linux ~~~~ 2.6.12-12mdk #1 F
Votes:1 Avg. Score:4.0 ± 0.0 Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%) Same OS:0 (0.0%)
View/Vote Developer Edit Submission

[21 Mar 2007 4:00pm UTC] 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
)
[22 Mar 2007 10:25am UTC] tony2001@php.net
>I guess could have the answer in the bug 24159...
Right, so this is expected.
[20 Feb 2008 3:55pm UTC] 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.
[23 Nov 12:52pm UTC] 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)
[23 Nov 12:52pm 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.


RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC