Easy Tutorial
❮ Func Directory Chdir Func String Vfprintf ❯

PHP join() Function

PHP String Reference Manual

Example

Combine array elements into a string:


Definition and Usage

The join() function returns a string formed by concatenating the elements of an array.

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

Note: The join() function accepts two parameter orders. However, due to historical reasons, explode() does not allow this; you must ensure that the separator parameter precedes the string parameter.

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


Syntax

Parameter Description
separator Optional. Specifies what to place between the array elements. Default is "" (an empty string).
array Required. The array whose elements are to be joined into a string.

Technical Details

Return Value: Returns a string formed by joining array elements.
PHP Version: 4+
--- ---
Changelog: As of PHP 4.3.0, the separator parameter became optional.
--- ---

More Examples

Example 1

Separate array elements with different characters:


❮ Func Directory Chdir Func String Vfprintf ❯