join()

join() — Alias of implode().

Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

join() is an alias of implode(): same parameters, same return value.

Signature

join(string $separator, array $array): string join(array $array): string join(array $array, string $separator): string

Parameters

ParameterTypeWhat it takes
$separatorstringOptional. Defaults to an empty string.
$arrayarrayThe array of strings to implode.

Return value

Returns a string containing a string representation of all the array elements in the same order, with the separator string between each element.

Example

A runnable snippet:

$array = ['lastname', 'email', 'phone']; var_dump(implode(",", $array)); // string(20) "lastname,email,phone" // Empty string when using an empty array: var_dump(implode('hello', [])); // string(0) "" // The separator is optional: var_dump(implode(['a', 'b', 'c'])); // string(3) "abc"

All PHP 8.5 built-in functions

Reference card built from the PHP manual page join() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.