Home > php教程 > php手册 > body text

PHP 字符串转换成数组str_split

PHPz
Release: 2018-09-30 14:51:30
forward
1459 people have browsed it

PHP 字符串转换成数组str_split

将连续的字符串转换成单个的字符数组

例子:

<?php
    $str = &#39;abcde&#39;;
    $arr1 = str_split($str);
    print_r($arr1);
?>
Copy after login

输出结果如下:

Array
(
    [0] => a
    [1] => b
    [2] => c
    [3] => d
    [4] => e
)
Copy after login

其与explode的区别是:explode第一个参数必须传一个切分字符(如:,  |  空格 )才能进行分割;str_split则直接进行分割

更多相关教程请访问 php编程从入门到精通全套视频教程

Related labels:
php
source:csdn.net
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!