(PHP 4 >= 4.2.0, PHP 5)
array_fill — Preenche um array com valores
Preenche um array com num elementos com o valor do parâmetro value , e chaves começando a partir de start_index .
The first index of the returned array
Number of elements to insert
Values to use filling
Returns the filled array
Throws a E_WARNING if num is less than one.
Exemplo #1 Exemplo da array_fill()
<?php
$a = array_fill(5, 6, 'banana');
$b = array_fill(-2, 2, 'pear');
print_r($a);
print_r($b);
?>
O exemplo acima irá imprimir:
Array ( [5] => banana [6] => banana [7] => banana [8] => banana [9] => banana [10] => banana ) Array ( [-2] => pear [0] => pear )
Veja também a seção Arrays do manual para a explicação detalhada de chaves negativas.