Heim  >  Artikel  >  php教程  >  php-Arrays函数-array_fill-用给定的值填充数组

php-Arrays函数-array_fill-用给定的值填充数组

WBOY
WBOYOriginal
2016-06-13 10:49:471242Durchsuche

array_fill() 函数 用给定的值填充数组

【功能】
         该函数将返回一个新的数组,
         该数组用被指定的数量的指定内容填充。
【使用范围】
         php4 > 4.2.0、php5.
【使用】
         array array_fill( int start_index, int num, mixed value )
         start_index/必需/新数组中键名的开始数
         num/必需/为新数组填充的个数,该值必须是一个大于零的值,否则php会发出一条警告
         value/必需/为新数组中的值
【示例】
[php]
print_r( array_fill( 5, 6, "hehe" ) ); 
/*
Array
(
    [5] => hehe
    [6] => hehe
    [7] => hehe
    [8] => hehe
    [9] => hehe
    [10] => hehe
)
*/ 

 


摘自 zuodefeng的笔记

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn