Blogger Information
Blog 142
fans 5
comment 0
visits 130090
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php把字符串指定字符分割成数组的方法
php开发大牛
Original
983 people have browsed it

实例如下:

<?php
$str="1|2|3|4|5|";
$var=explode("|",$str);
print_r($var);
?>
$var=explode("|",$str);

把$str按|进行分割

php还有其他的把字符串指定字符分割成数组

str_split(string,length)

参数 描述

string 必需。规定要分割的字符串。 

length 可选。规定每个数组元素的长度。默认是 1。

json_decode()这个函数也可以把字符串分割成数组 (第二个参数为true才行)


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post