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