mb_ereg_replace()

mb_ereg_replace() — Replace regular expression with multibyte support.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

Scans string for matches to pattern, then replaces the matched text with replacement

Signature

mb_ereg_replace(string $pattern, string $replacement, string $string, ?string $options = null): string|false|null

Parameters

ParameterTypeWhat it takes
$patternstringThe regular expression pattern.
$replacementstringThe replacement text.
$stringstringThe string being checked.
$options?stringThe search option. See mb_regex_set_options() for explanation.

Return value

The resultant string on success, or false on error. If string is not valid for the current encoding, null is returned.

Example

The PHP manual ships no example for mb_ereg_replace(); the signature and the parameter table above are the contract.

Changelog

VersionChange
8.0.0options is nullable now.
7.1.0The function checks whether string is valid for the current encoding.
7.1.0The e modifier has been deprecated.

See also

mb_regex_encoding(), mb_eregi_replace()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page mb_ereg_replace() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.