php tutorial explode split str_split function difference and examples
The three functions all split a string into an array, but each has its own usage. Let’s take a look at the differences and examples of the php explode split str_split function one by one.
*/
$str ="id_99_cn.html";
$array = explode('_',$str);
print_r($array);
/*
array
(
[0] => id
[1] => 99
[2] => cn.html
)
*/
//Function prototype: array split (string $pattern, string $string [, int $limit])
$split = split('_',$str);
print_r($split);
/*
array
(
[0] => id
[1] => 99
[2] => cn.html
)
*/
//str_split() function splits a string into an array.
$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
)
Original articles on this site are reprinted from http://www.bKjia.c0m