array array_fill ( int $start_index , int $num , mixed $value )
参数说明:<?php $a = array_fill(5, 6, 'banana'); //使用banana填充数组到6个元素, 索引键由数字5开始 $b = array_fill(-2, 4, 'pear'); //使用pear填充数组到4个元素, 索引键由-2开始 $c = array_fill(3, 2, array('PHP ','http://task.lmcjl.com/php/', 'C语言中文网')); // 用一个数组填充成一个二维数组 print_r($a); print_r($b); print_r($c); ?>运行结果如下:
Array
(
[5] => banana
[6] => banana
[7] => banana
[8] => banana
[9] => banana
[10] => banana
)
Array
(
[-2] => pear
[0] => pear
[1] => pear
[2] => pear
)
Array
(
[3] => Array
(
[0] => PHP
[1] => http://task.lmcjl.com/php/
[2] => C语言中文网
)
[4] => Array
(
[0] => PHP
[1] => http://task.lmcjl.com/php/
[2] => C语言中文网
)
)
本文链接:http://task.lmcjl.com/news/7565.html