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
)