mb_split
Splitting multibyte strings using regular expressions
Function name: mb_split()
Applicable version: PHP 4 >= 4.2.0, PHP 5, PHP 7
Function description: The mb_split() function uses a multibyte character set to split strings and returns an array composed of segmented substrings.
Syntax: mb_split(string $pattern, string $string [, int $limit = -1])
parameter:
Return value: Returns an array composed of divided substrings, and returns FALSE if splitting fails.
Example:
// 使用空格分割字符串$str = "Hello World"; $result = mb_split(" ", $str); print_r($result); // Output: Array ( [0] => Hello [1] => World ) // 使用正则表达式分割字符串$str = "Hello,World"; $result = mb_split("[,]", $str); print_r($result); // Output: Array ( [0] => Hello [1] => World ) // 限制返回的数组元素个数$str = "Hello World"; $result = mb_split(" ", $str, 1); print_r($result); // Output: Array ( [0] => Hello )
Notes: