The array_fill() function fills an array with values.
PHP array_fill() function has the following syntax.
array_fill(index,number,value);
PHP array_fill() function has the following syntax.
Parameter | Is Required | Description |
---|---|---|
index | Required. | The first index |
number | Required. | Number of elements to insert |
value | Required. | Value to fill the array |
Fill an array with values:
<?php
$a1=array_fill(3,4,"java2s.com");
print_r($a1);
?>
The code above generates the following result.