Latest Code Tutorials

PHP join: How to Join Array Elements in PHP

The join() function is an inbuilt function in PHP and is used to join the array of elements that are separated by the string.

PHP join()

PHP join() is an inbuilt function that returns the string from the items of an array. The join() function is an alias of an implode() function. The separator parameter of join() is optional. However, it is recommended to always use the two parameters for backward compatibility.


The syntax of join() function is the following.



The separator parameter is optional, and it specifies what to put between the array elements. Default is ” “.

The array parameter is required, and it is the array to join.

See the following example.


// app.php

$data = ['Google', 'Youtube', 'Facebook', 'Amazon'];
echo join(" ",$data)."\n";
echo join(" + ",$data)."\n";
echo join(" - ",$data)."\n"; 
echo join(" | ",$data);

See the below output.

PHP Join Example

That is it for the PHP join() Function.

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.