Home > Backend Development > PHP Tutorial > php中的implode 跟 explode

php中的implode 跟 explode

WBOY
Release: 2016-06-13 11:52:08
Original
1156 people have browsed it

php中的implode 和 explode

我在开发php程序的时候遇到了不少问题,一路上也算是磕磕绊绊,但是最后还是过五关斩六将,该实现的功能都实现了。下面的两个函数是我在开发过程中用到过的一组。这组函数主要是实现了字符串的拆分,以及字符串的组合。程序员就习惯看例子,下面来看一组实例。

?

拆分字符数串函数explode()

其中$row['logistics']的值的格式类似于:1,2,3,4,5,6,7,8

$logistics=explode(",", $row['logistics']);$count  =  count($logistics);for($i=0;$i<$count;$i++){	echo $logistics[$i];}
Copy after login
?这样我打印出来的就是1 2 3 4 5 6 7 8。

?

拼接字符串函数implode()

<?php$arr = array('Hello','World!');echo implode(" ",$arr);?>
Copy after login

输出:Hello World!

好了,现在你要用这些数据干嘛就看你自己咯。。

?

Related labels:
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