Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

mb_split

Description

Split multibyte string using regular expression

Syntax

mb_split(
    string $pattern,
    string $string,
    int $limit = -1
): array|false

Parameters

pattern

The regular expression pattern.

string

The string being split.

limit

If optional parameter limit is specified, it will be split in limit elements as maximum.

Return

The result as an array, or false on failure.

Examples

1 · pattern string

<?

$pattern = '🐘';
$string = 'string🐘string🐘string';

$return = mb_split($pattern, $string);

print_r($return);

?>
Array
(
    [0] => string
    [1] => string
    [2] => string
)

2 · limit

<?

$pattern = '🐘';
$string = 'string🐘string🐘string';
$limit = 2;

$return = mb_split($pattern, $string, $limit);

print_r($return);

?>
Array
(
    [0] => string
    [1] => string🐘string
)
HomeMenu