Example 1 — Filling an Array With One Value
Create three items that all hold the same text.
<?php
$filled = array_fill(0, 3, 'x');
print_r($filled); How It Works
- The first argument 0 is the key of the first item.
- The second argument 3 asks for three items.
- The third argument 'x' is the value stored in every item.
- The keys increase by 1 each time, giving 0, 1 and 2.

