Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 10:49:47
Original
1242 people have browsed it

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的笔记

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!