PHP array_fill() Function

PHP array_fill Function


Description :

In PHP array_fill() function returns an array filled with specified value with specified number of times and the index of the array starts from specified index. 

In other words array_fill() function fills an array with values.

Syntax :
    array_fill(start_index, count, value)

Parameters

start_index Required. Specify the staring index of the returned array.
count Required. Specify the number of elements inserted.
value Required. Specify the value to be inserted.

we can see below Example :

 

Output :

Array
(
    [1] => web
    [2] => web
    [3] => web
    [4] => web
    [5] => web
)

Array
(
    [-2] => designing
    [-1] => designing
    [0] => designing
    [1] => designing
    [2] => designing
    [3] => designing
)