Replacing Substrings

Learn how to find and replace strings within an existing string.

We'll cover the following...

The replace helper method

The replace helper method can find and replace strings within an existing string. We can also use this method to replace multiple strings within a single value or even replace multiple strings across many values.

Press + to interact
<?php
/**
* Versions: Laravel 8, 9
*
* @return string
*/
public static function replace(
string|string[] $search,
string|string[] $replace,
string|string[] $subject
);

The replace helper is useful for, but not limited to: ...