欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

array_fill(1, 5, 'apple')从索引1开始,填充5个apple

程序员文章站 2024-02-14 17:15:16
...
<?php
$a = array_fill(1, 5, 'apple');
print_r($a);
$b = array_fill(-2, 4, 'pear');
print_r($b);
输出:
Array
(
    [1] => apple
    [2] => apple
    [3] => apple
    [4] => apple
    [5] => apple
)
Array
(
    [-2] => pear
    [0] => pear
    [1] => pear
    [2] => pear
)