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
| Parameter | Type | What it takes |
|---|---|---|
| $pattern | string | The regular expression pattern. |
| $replacement | string | The replacement text. |
| $string | string | The string being checked. |
| $options | ?string | The 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
| Version | Change |
|---|---|
| 8.0.0 | options is nullable now. |
| 7.1.0 | The function checks whether string is valid for the current encoding. |
| 7.1.0 | The 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.