Heim  >  Artikel  >  Backend-Entwicklung  >  php join() 函数,phpjoin函数_PHP教程

php join() 函数,phpjoin函数_PHP教程

WBOY
WBOYOriginal
2016-07-12 08:52:561042Durchsuche

php join() 函数,phpjoin函数

php join() 函数获取由数组元素组合成的字符串。本文章向码农介绍php join() 函数的使用方法和基本实例,感兴趣的码农可以参考一下。

定义和用法

join() 函数返回由数组元素组合成的字符串。

join() 函数是 implode() 函数的别名。

注释:join() 函数接受两种参数顺序。但是由于历史原因,explode() 是不行的,您必须保证 separator 参数在 string 参数之前才行。

注释:join() 函数的 separator 参数是可选的。但是为了向后兼容,推荐您使用使用两个参数。

 

语法

<code class="language-php hljs">join(separator,<span class="hljs-keyword">array)</span></code>
参数 描述
separator 可选。规定数组元素之间放置的内容。默认是 ""(空字符串)。
array 必需。要组合为字符串的数组。

 

技术细节

返回值: 返回由数组元素组合成的字符串。
PHP 版本: 4+
更新日志: 在 PHP 4.3.0 中,separator 参数变成可选的。

 

实例

用不同的字符分隔数组元素:

<?php
$arr = array('Hello','World!','I','love','Shanghai!');
echo join(" ",$arr)."<br>";
echo join("+",$arr)."<br>";
echo join("-",$arr)."<br>";
echo join("X",$arr);
?>

在线运行

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1125684.htmlTechArticlephp join() 函数,phpjoin函数 php join() 函数获取由数组元素组合成的字符串。本文章向码农介绍php join() 函数的使用方法和基本实例,感兴趣的...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn