English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The PHP array_fill() function fills an array with a given value
array array_fill( int start_index, int num, mixed value );
start_index
The first index value of the returned array.
If start_index is negative, the first index of the returned array will be start_index, and the subsequent indices will start from 0. (See Example).
num
The number of elements to insert. Must be greater than or equal to 0.
value
The value to be filled in.
Number | Parameters and Description |
---|---|
1 | start_index Returns the first index of the array |
2 | num It contains the number of elements to insert |
3 | value It contains the values used to fill |
It returns an array filled with values
<?php $input = array_fill(5, 6, 'apple'); print_r($input); ?>Test and See ‹/›
Output Result:
Array ( [5] => apple [6] => apple [7] => apple [8] => apple [9] => apple [10] => apple )