mb_ereg_search_pos()

mb_ereg_search_pos() — Returns position and length of a matched part of the multibyte regular expression for a predefined multibyte string.

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_search_pos(?string $pattern = null, ?string $options = null): array|false

Parameters

ParameterTypeWhat it takes
$pattern?stringThe search pattern.
$options?stringThe search option. See mb_regex_set_options() for explanation.

Return value

An array containing two elements. The first element is the offset, in bytes, where the match begins relative to the start of the search string, and the second element is the length in bytes of the match. If an error occurs, false is returned.

Example

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

Changelog

VersionChange
8.0.0pattern and options are nullable now.

See also

mb_regex_encoding(), mb_ereg_search_init()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page mb_ereg_search_pos() (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.