教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php array_fill函数怎么用

php array_fill函数怎么用

发布时间:2020-12-01   编辑:jiaochengji.com
教程集为您提供php array,fill函数怎么用等资源,欢迎您收藏本站,我们将为您提供最新的php array,fill函数怎么用资源
php array_fill函数作用是用键值填充数组,其语法是array_fill(index,number,value),参数index必需,是被返回数组的第一个索引;number必需,是规定要插入的元素数;value 必需,规定供填充数组所使用的值。

php array_fill函数怎么用?

作用:用键值填充数组。

语法:

array_fill(index,number,value)

参数:

index 必需。被返回数组的第一个索引。

number 必需。规定要插入的元素数。

value 必需。规定供填充数组所使用的值。

说明:

用给定的值填充数组,返回的数组有 number 个元素,值为 value。返回的数组使用数字索引,从 start 位置开始并递增。如果 number 为 0 或小于 0,就会出错。

php array_fill()函数使用示例1

<?php
$a=array_fill(2,3,"无忌");
print_r($a);
?>

输出:

Array ( [2] => 无忌 [3] => 无忌 [4] => 无忌 )

php array_fill()函数使用示例2

<?php
$a=array_fill(1,2,"西门");
print_r($a);
?>

输出:

Array ( [1] => 西门 [2] => 西门 )

以上就是php array_fill函数怎么用的详细内容,更多请关注教程集其它相关文章!

  • 本文原创发布教程集,转载请注明出处,感谢您的尊重!
  • 您可能感兴趣的文章:
    php array_fill函数怎么用
    php数组入门教程之数组填充
    php如何建一个数组
    学习php抽奖程序之几率算法
    PHP写时复制(Copy On Write)
    5种PHP创建数组的方法
    php 数组相关处理函数
    php程序员面试题(经典汇总)
    php 数组的指针操作(php数组函数汇总)
    一些php数组的学习入门笔记

    [关闭]
    ~ ~