Rumah > Artikel > pembangunan bahagian belakang > php explode split str_split函数区别与实例_PHP教程
php教程 explode split str_split函数区别与实例
三个函数都是把一个字符串分割成一个数组,但各有各的用法,下面我们就一一来看关于php explode split str_split函数区别与实例吧。
*/
$str ="id_99_cn.html";
$array = explode('_',$str);
print_r($array);
/*
array
(
[0] => id
[1] => 99
[2] => cn.html
)
*/
//函数原型:array split (string $pattern, string $string [, int $limit])
$split = split('_',$str);
print_r($split);
/*
array
(
[0] => id
[1] => 99
[2] => cn.html
)
*/
//str_split() 函数的字符串分割成一个数组。
$str_split = str_split($str,2);
print_r($str_split);
/*
array
(
[0] => id
[1] => _9
[2] => 9_
[3] => cn
[4] => .h
[5] => tm
[6] => l
)
本站原创文章转载注明来源于http://www.bKjia.c0m