> For the complete documentation index, see [llms.txt](https://arrayutils.docs.present.kim/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://arrayutils.docs.present.kim/methods/c/replace.md).

# replace()

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

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

$arrayUtils = ArrayUtils::from(["orange", "banana", "apple", "raspberry", "kiwi"]);


$arrayUtils->replace([0 => "pineapple", 4 => "cherry"]);
// expected output: ["pineapple", "banana", "apple", "raspberry", "cherry"]
```

{% endcode %}

## Syntax

```php
$arrayUtils->replace(iterable ...$iterables) : ArrayUtils;
```

### Parameter

* `$iterables`

  > Arrays to replace.

###

### Return value

* A replaced array.

## Prefixing

```php
$arrayUtils->replaceAs(iterable ...$iterables) : array;
```

```php
ArrayUtils::replaceFrom(iterable $from, iterable ...$iterables) : ArrayUtils;
```

```php
ArrayUtils::replaceFromAs(iterable $from, iterable ...$iterables) : array;
```

## References

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