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

PHP函数implode()与explode()函数的不同之处

WBOY
Release: 2016-06-13 11:07:22
Original
952 people have browsed it

在以前的文章中我们曾经向大家介绍了explode() 函数的具体用法。当我们遇到PHP函数implode()把数组元素组合为一个字符串。
implode(separator,array)
separator 可选。规定数组元素之间放置的内容。默认是 ""(空字符串)。
array 必需。要结合为字符串的数组。
虽然 separator 参数是可选的。但是为了向后兼容,推荐您使用使用两个参数。


PHP函数implode()的例子
 

<ol class="dp-xml">
<li class="alt"><span><span class="tag"></span><span class="tag-name">php</span><span> </span></span></li>
<li>
<span>$</span><span class="attribute">arr</span><span> = </span><span class="attribute-value">array</span><span>('Hello','World!','Beautiful','Day!');  </span>
</li>
<li class="alt"><span>echo implode(" ",$arr);  </span></li>
<li>
<span class="tag">?></span><span> </span>
</li>
</ol>
Copy after login

输出:

Hello World! Beautiful Day!

上面这段代码示例就是PHP函数implode()的具体实现功能的展现。


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