php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #40882 array_fill with negative start index not documented
Submitted: 2007-03-21 16:00 UTC Modified: 2009-11-23 12:52 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: guile_spam at laposte dot net Assigned: nicholsr (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.2.1 OS: Linux ~~~~ 2.6.12-12mdk #1 F
Private report: No CVE-ID: None
 [2007-03-21 16:00 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
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-22 10:25 UTC] tony2001@php.net
>I guess could have the answer in the bug 24159...
Right, so this is expected.
 [2008-02-20 15:55 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.
 [2009-11-23 12:52 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)
 [2009-11-23 12:52 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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 01:01:30 2024 UTC