php array_fill() function
Translation results:
英[fɪl] 美[fɪl]
vt.& vi. (to make) full, (to make) full
vt. To satisfy; to prepare medicine; (to supply according to order); To fill with (feeling)
n. The amount of filling; sufficient; filling; embankment
Third person singular: fills Plural: fills Present participle: filling Past tense: filled Past participle: filled
php array_fill() functionsyntax
Function:Fill the array with key value
Syntax: array_fill(index,number,value)
Parameters:
Parameter | Description |
index | Required. The first index of the returned array. |
number | Required. Specifies the number of elements to insert. |
value | Required. Specifies the values used to populate the array. |
Description: Fill the array with the given value. The returned array has number elements and the value is value. The returned array is numerically indexed, starting at position start and increasing. If number is 0 or less than 0, an error occurs.
php array_fill() functionexample
<?php $a=array_fill(2,3,"无忌"); print_r($a); ?>
Run instance»
Click the "Run instance" button to view the online instance
Output:
Array ( [2] => 无忌 [3] => 无忌 [4] => 无忌 )
<?php $a=array_fill(1,2,"西门"); print_r($a); ?>
Run Instance»
Click the "Run Instance" button to view the online instance
Output:
Array ( [1] => 西门 [2] => 西门 )