← All built-ins / preg_replace()
preg_replace()
preg_replace(...$args): string
Parameters
| Name | Type | Description |
|---|---|---|
| $pattern | string | /…/ pattern |
| $replacement | string | replacement; $1..$n reference capture groups |
| $subject | string | string to modify |
Return value
The string with every match replaced.
Example
echo preg_replace("/\s+/", "_", "holy php lang"), "
";
echo preg_replace("/(\w+)@(\w+)/", "$2/$1", "ada@holy"), "
";holy_php_lang holy/ada