Home > php教程 > php手册 > php explode split str_split函数区别与实例

php explode split str_split函数区别与实例

WBOY
Release: 2016-06-13 10:03:22
Original
1785 people have browsed it

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

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template