PHP array_fill()Functions
Examples
Fill an array with the given value:
<?php
$a1=array_fill(3,4,"blue");
print_r($a1);
?>
$a1=array_fill(3,4,"blue");
print_r($a1);
?>
Run Example »
Definition and Usage
The array_fill() function fills an array with the given value.
Syntax
array_fill(index,number,value);
| Parameters | Description |
|---|---|
| index | Required. Specifies the starting index of the returned array. |
| number | Required. Specifies the number of elements to fill, which must be greater than 0. |
| value | Required. Specifies the value used to fill the array. |
Technical Details
| Return value: | Returns the filled array. |
|---|---|
| PHP Version: | 4.2+ |
Complete PHP Array Reference Other Extensions