Skip to content

Kirby 4.2.0


Replaces all or some occurrences of the search string with the replacement string Extension of the str_replace() function in PHP with an additional $limit parameter

Str::replace(Kirby\Toolkit\Collection|array|string $string, Kirby\Toolkit\Collection|array|string $search, Kirby\Toolkit\Collection|array|string $replace, array|int $limit = -1): array|string


Name Type Default Description
$string * Kirby\Toolkit\Collection|array|string String being replaced on (haystack); can be an array of multiple subject strings
$search * Kirby\Toolkit\Collection|array|string Value being searched for (needle)
$replace * Kirby\Toolkit\Collection|array|string Value to replace matches with
$limit array|int -1 Maximum possible replacements for each search value;
multiple limits for each search value are supported;
defaults to no limit

Return type


Parent class