array_fill
用給定的值填充數組
array_fill()
函數用鍵值填充數組。
array_fill()
函數用給定的值填充數組,返回的數組有number個元素,值為value 。返回的數組使用數字索引,從start位置開始並遞增。如果number為0 或小於0,就會出錯。
用值填充數組:
<?php $a1 = array_fill ( 3 , 4 , "blue" ) ; print_r ( $a1 ) ; ?>
親自試一試
array_fill ( index , number , value ) ;
參數 | 描述 |
---|---|
index | 必需。被返回數組的第一個索引。 |
number | 必需。規定要插入的元素數。 |
value | 必需。規定供填充數組所使用的值。 |