array_fill
(PHP 4 >= 4.2.0, PHP 5)
array_fill — Füllt ein Array mit Werten
Beschreibung
array array_fill
( int $start_index
, int $num
, mixed $value
)
array_fill() füllt ein Array mit num Einträgen des Wertes des value Parameters. Die Indizes des Arrays beginnen mit dem start_index Parameter. Beachten Sie, dass num eine Zahl größer als Null sein muss, ansonsten gibt PHP eine Warnung aus.
Example#1 array_fill()
<?php
$a = array_fill(5, 6, 'Banane');
print_r($a);
?>
Nun ist $a:
Array ( [5] => Banane [6] => Banane [7] => Banane [8] => Banane [9] => Banane [10] => Banane )
Siehe auch str_repeat() und range().