PHP array_fill() function
Example
Fill the array with values:
<?php $a1=array_fill(3,4,"blue"); print_r($a1); ?>
Definition and Usage
The array_fill() function fills the array with keys.
Description
The array_fill() function fills the array with the given value, and the returned array has number elements, with a value of value. The returned array uses numeric indexing, starting from start Start from the position and increment. If number If 0 or less, an error will occur.
Syntax
array_fill(index,number,value);
Parameter | Description |
---|---|
index | Required. The first index of the returned array. |
number | Required. Specifies the number of elements to be inserted. |
value | Required. Specifies the values to be used to fill the array. |
Technical Details
Return Value: | Return the filled array. |
PHP Version: | 4.2+ |