-
12月04日
-
【函数功能】
该函数用给定的值填充数组,返回的数组有num个元素,值为value。返回的数组使用数字索引,从start_index位置开始并递增。如果 num小于0,返回false。
【函数语法】
array_fill ($start_index, $num, $value)
【参数说明】
strat_index:必需,被返回数组的第一个索引。 $num:必需,要插入的元素数。 $value:必需,供填充数组所使用的值。
【演示程序】
<?php /** * array_fill ($start_index, $num, $value) * **/ $arr = array_fill(3, 2, 'php1234.cn'); var_dump($arr); echo '<br>'; $arr = array_fill(3, 0, 'php1234.cn'); var_dump($arr); ?>
【输出结果】
array(2) { [3]=> string(10) "php1234.cn" [4]=> string(10) "php1234.cn" } array(0) { }
【特别注意】
1.如果$num为0,则返回空数组,小于0则返回false。 2.如果$start_index不是数字,则返回null。 3.PHP 版本:4.2+。
【原版定义】
/** * Fill an array with values * @link http://www.php.net/manual/en/function.array-fill.php * @param start_index int <p> * The first index of the returned array. * </p> * <p> * If start_index is negative, * the first index of the returned array will be * start_index and the following * indices will start from zero * (see example). * </p> * @param num int <p> * Number of elements to insert. * Must be greater than zero. * </p> * @param value mixed <p> * Value to use for filling * </p> * @return array the filled array */
转载请注明出处:php1234.cn ,原文地址:http://www.php1234.cn/a/functions/2016/1204/147.html
收藏文章

登录
表情删除后不可恢复,是否删除
取消
确定
图片正在上传,请稍后...
取消上传
评论内容为空!
还没有评论,快来抢沙发吧!
畅言云评
站长点击我去广告>
热评话题
- PHP数组其他类函数array_walk_recursive_PHP1234|PHP修炼之路|跟着明礼馨德一起修炼PHP
- 礼者,人之所履,夙兴夜寐,以成人伦之序_PHP1234|PHP修炼之路|跟着明礼馨德一起修炼PHP
- PHP Variable函数之判断变量函数之is_real_PHP1234|PHP修炼之路|跟着明礼馨德一起修炼PHP
- 德者,人之所得,使万物各得其所欲_PHP1234|PHP修炼之路|跟着明礼馨德一起修炼PHP
- 义者,人之所宜,赏善罚恶,以立功立事_PHP1234|PHP修炼之路|跟着明礼馨德一起修炼PHP
- 夫欲为人之本,不可无一焉_PHP1234|PHP修炼之路|跟着明礼馨德一起修炼PHP
- 仁者,人之所亲,有慈惠恻隐之心,以遂其生成_PHP1234|PHP修炼之路|跟着明礼馨德一起修炼PHP