PHP join() Function
Example
Join array elements with a string:
<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo join(" ",$arr);
?>
Try it Yourself »
Definition and Usage
The join() function is alias of implode().
Syntax
join(separator,array)
Parameter Values
| 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 |
Technical Details
| Return Value: | Returns a string from elements of an array |
|---|---|
| PHP Version: | 4+ |
More Examples
Example
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);
?>
Try it Yourself »
❮ PHP String Reference