PHP – mb_split(多字节拆分)函数
PHP 中的 mb_split() 函数用于使用正则表达式拆分多字节字符串。它以数组格式返回结果。
语法
array mb_split($str_pattern, $str_string, int $limit=-1)
参数
mb_split() 接受以下三个参数 −
$str_pattern − 用于正则表达式的模式。
$str_string − 用于拆分字符串。
$limit − 这是一个可选参数,用于指定限制元素。
返回值
mb_split 函数将以数组的形式返回拆分元素结果。或者,它将在失败时返回 False。
示例 1
<?php
mb_internal_encoding("UTF-8");
//mb_split function will split the string
$string = mb_split(
"[ ,]+", // Pattern
"Welcome to the PHP Tutorial"); // string
print_r($string);
?>输出
它将产生以下输出 −
Array ( [0] => Welcome [1] => to [2] => the [3] => PHP [4] => Tutorial )
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP