# fill()

{% code title="Example.php" %}

```php
<?php use kim\present\utils\arrays\ArrayUtils;

$arrayUtils = ArrayUtils::from(range(1, 10));

//Full fill with 0
$arrayUtils->fill(0);
// expected output: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

//Fill with 0 from position 2 until position 4
$arrayUtils->fill(0, 2, 4);
// expected output: [1, 2, 0, 0, 5, 6, 7, 8, 9, 10]

//Fill with 0 from position 4 until end
$arrayUtils->fill(0, 4);
// expected output: [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
```

{% endcode %}

## Syntax

```php
$arrayUtils->fill(mixed $value, int $start = 0, int $end = null) : ArrayUtils;
```

### Parameter

* `$value`&#x20;

  > Value to fill the array with.
* `$start`<img src="https://2976351099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKYhyHaArG9Gsnmdxc8%2F-MKk9I82AGQBHkmwnVvk%2F-MKk9YjCz_YkVR1YiRy-%2FBADGE_OPTIONAL.svg?alt=media&#x26;token=3fbbac84-2f1b-40af-a991-b2eff659866a" alt="" data-size="line">&#x20;

  > Start index, default `0`.
* `$end` <img src="https://2976351099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKYhyHaArG9Gsnmdxc8%2F-MKk9I82AGQBHkmwnVvk%2F-MKk9YjCz_YkVR1YiRy-%2FBADGE_OPTIONAL.svg?alt=media&#x26;token=3fbbac84-2f1b-40af-a991-b2eff659866a" alt="" data-size="line">&#x20;

  > End index, default `count($array)`.

### Return value

* A filled array.

## Prefixing

```php
$arrayUtils->fillAs(mixed $value, int $start = 0, int $end = null) : array;
```

```php
ArrayUtils::fillFrom(iterable $from, mixed $value, int $start = 0, int $end = null) : ArrayUtils;
```

```php
ArrayUtils::fillFromAs(iterable $from, mixed $value, int $start = 0, int $end = null) : array;
```

## References

{% embed url="<https://www.php.net/manual/en/function.array-fill-keys>" %}
