mb_ereg()
mb_ereg() — Regular expression match 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.
Signature
mb_ereg(string $pattern, string $string, array &$matches = null): bool
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $pattern | string | The search pattern. |
| $string | string | The search string. |
| &$matches | array | If matches are found for parenthesized substrings of pattern and the function is called with the third argument matches, the matches will be stored in the elements of the array matches. If no matches are found, matches is set to an empty array. |
Return value
Returns whether pattern matches string.
Example
The PHP manual ships no example for mb_ereg(); the signature and the parameter table above are the contract.
Changelog
| Version | Change |
|---|---|
| 8.0.0 | This function returns true on success now. Previously, it returned the byte length of the matched string if a match for pattern was found in string and matches was passed. If the optional parameter matches was not passed or the length of the matched string was 0, this function returned 1. |
| 7.1.0 | mb_ereg() will now set matches to an empty array, if nothing matched. Formerly, matches was not modified in that case. |
See also
mb_regex_encoding(), mb_eregi()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page mb_ereg() (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.