|
array_fillFill an array with values Description
array array_fill(int
$start_index, int $count, mixed $value)
Fills an array with
Parameters
Return ValuesReturns the filled array Errors/Exceptions
Throws a ValueError if Changelog
Examples
Example #1 array_fill example The above example will output:
Array
(
[5] => banana
[6] => banana
[7] => banana
[8] => banana
[9] => banana
[10] => banana
)
Example #2 array_fill example with a negative start index Output of the above example in PHP 8:
Array
(
[-2] => pear
[-1] => pear
[0] => pear
[1] => pear
)
Output of the above example in PHP 7:
Array
(
[-2] => pear
[0] => pear
[1] => pear
[2] => pear
)
Note that index NotesSee also the Arrays section of manual for a detailed explanation of negative keys. See Also
|