array_fill
Fill the array with the given value
array_fill()
function fills the array with key values.
array_fill()
function fills the array with the given value. The returned array has number elements and the value is value . The returned array uses a numeric index, starting from the start position and incrementing. If number is 0 or less than 0, an error occurs.
Fill the array with values:
<?php $a1 = array_fill ( 3 , 4 , "blue" ) ; print_r ( $a1 ) ; ?>
Try it yourself
array_fill ( index , number , value ) ;
parameter | describe |
---|---|
index | Required. The first index of the array is returned. |
number | Required. Specifies the number of elements to be inserted. |
value | Required. Specifies the value used to fill the array. |