Array Fill Function in PHP
In this article I explain the PHP array_fill function.
Introduction
The array_fill function is used to fill an array with values, returns the filled array.
Syntax
array_fill(start, number, array) |
Parameter in array_fill Function
Parameter |
Description |
start |
It specifies starting index of the key. |
number |
It specifies number of elements to insert but must be greater than one. |
array |
It specifies value to be inserted. |
Example of array_fill Function
<?php
echo "<pre>";
$a = array_fill(1, 2, 'banana');
print_r($a);
echo "<pre>";
$a = array_fill(1, 3, 'Apple');
print_r($a);
?>
Output