Home >Backend Development >PHP Tutorial >In PHP, the array_fill() function is used to fill an array with a specified value.
array_fill() function is used to fill the values of the array. It returns the populated array. It returns the populated array.
array_fill(start_index, num, value)
start_index − Returns the first index of the array. Required.
num − The number of elements to insert. Required.
value − The value to fill the array. Required.
array_fill() function returns the filled array.
The Chinese translation ofReal-time demonstration
<?php $a = array_fill(3, 5, 'demo'); print_r($a); ?>
Array ( [3] => demo [4] => demo [5] => demo [6] => demo [7] => demo )
The above is the detailed content of In PHP, the array_fill() function is used to fill an array with a specified value.. For more information, please follow other related articles on the PHP Chinese website!