php join() function, phpjoin function_PHP tutorial

WBOY
Release: 2016-07-12 08:52:56
Original
1075 people have browsed it

php join() function, phpjoin function

php join() function obtains a string composed of array elements. This article introduces to coders how to use the php join() function and basic examples. Interested coders can refer to it.

Definition and usage

join() function returns a string composed of array elements.

join() function is an alias of implode() function.

Note: The join() function accepts two parameter orders. However, due to historical reasons, explode() does not work. You must ensure that the separator parameter comes before the string parameter.

Note: The separator parameter of the join() function is optional. However, for backward compatibility, it is recommended that you use two parameters.

Grammar

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

Technical details

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

Example

Separate array elements with different characters:

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

Run online

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1125684.htmlTechArticlephp join() function, phpjoin function php join() function obtains a string composed of array elements. This article introduces to coders how to use the php join() function and basic examples. Those who are interested...
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