PHP - Function array_fill()
Syntax
array array_fill ( int $start_index, int $num, mixed $value );
Definition and Usage
It fills an array with num entries of the value of the value parameter, keys starting at the start_index parameter.
Parameters
| Sr.No | Parameter & Description |
|---|---|
| 1 |
start_index The first index of the returned array |
| 2 |
num It conttains the number of elements to insert |
| 3 |
value It contains the values to use filling |
Return Values
It returns the filled array
Example
Try out following example −
<?php $input = array_fill(5, 6, 'apple'); print_r($input); ?>
This will produce the following result −
Array ( [5] => apple [6] => apple [7] => apple [8] => apple [9] => apple [10] => apple )
php_function_reference.htm
Advertisements