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://c.biancheng.net/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://c.biancheng.net/php/
[2] => C語言中文網
)
[4] => Array
(
[0] => PHP
[1] => http://c.biancheng.net/php/
[2] => C語言中文網
)
)