Home >Backend Development >PHP Tutorial >php join function join phonetic symbol joinms join reading

php join function join phonetic symbol joinms join reading

WBOY
WBOYOriginal
2016-07-29 08:49:491580browse

php join() function gets 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.

Syntax

<code>join(separator,<span>array)</span></code>
Parameters Description
separator Optional. Specifies what is placed between array elements. Default is "" (empty string).
array Required. Arrays to be combined into strings.

Technical details

Return value: Returns a string composed of array elements.
PHP version: 4+
Change log: In PHP 4.3.0, the separator parameter becomes optional.

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);
?>

Run online

The above introduces the php join function, including join and php content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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