note 115216 added to function.array-fill
| From: | anatoliy at ukhvanovy dot name | Date: | Mon, 16 Jun 2014 10:00:48 +0000 |
| Subject: | note 115216 added to function.array-fill | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199683@lists.php.net to get a copy of this message | ||
If you need negative indices:
<?php
$b = array_fill(-2, 4, 'pear');//this is not what we want
$c = array_fill_keys(range(-2,1),'pear');//these are negative indices
print_r($b);
print_r($c);
?>
Here is result of the code above:
Array
(
[-2] => pear
[0] => pear
[1] => pear
[2] => pear
)
Array
(
[-2] => pear
[-1] => pear
[0] => pear
[1] => pear
)
----
Server IP: 72.52.91.14
Probable Submitter: 109.110.71.84
----
Manual Page -- http://php.net/manual/en/function.array-fill.php
Edit -- https://master.php.net/note/edit/115216
Del: integrated -- https://master.php.net/note/delete/115216/integrated
Del: useless -- https://master.php.net/note/delete/115216/useless
Del: bad code -- https://master.php.net/note/delete/115216/bad+code
Del: spam -- https://master.php.net/note/delete/115216/spam
Del: non-english -- https://master.php.net/note/delete/115216/non-english
Del: in docs -- https://master.php.net/note/delete/115216/in+docs
Del: other reasons-- https://master.php.net/note/delete/115216
Reject -- https://master.php.net/note/reject/115216
Search -- https://master.php.net/manage/user-notes.php