Differences and examples of php explode split str_split function_PHP tutorial

WBOY
Release: 2016-07-13 16:59:05
Original
1884 people have browsed it

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631358.htmlTechArticlephp 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 php expl one by one...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template