HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
PHP String Reference : Join array elements with a string
The join() function returns a string from the elements of an array.
The join() function is an alias of the implode() function.
Parameter | Description |
---|---|
separator | Optional. Specifies what to put between the array elements. Default is "" (an empty string) |
array | Required. The array to join to a string |
Return Value: | Returns a string from elements of an array |
---|---|
PHP Version: | 4+ |
Changelog: | The separator parameter became optional in PHP 4.3.0. |
Separate the array elements with different characters:
<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo join(" ",$arr)."<br>";
echo join("+",$arr)."<br>";
echo join("-",$arr)."<br>";
echo join("X",$arr);
?>
❮ PHP String Reference