AppDividend
Latest Code Tutorials

PHP Join Example | PHP join() Function Tutorial

0

PHP Join Example | PHP join() Function Tutorial is today’s topic. The join() function returns the string from the items of an array. PHP 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.

PHP Join Example

The join() function is a built-in function in PHP and is used to join the array of items which are separated by the string. The syntax of join() function is following.

join(separator,array)

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.

<?php

// 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 Example | PHP join() Function Tutorial.

Leave A Reply

Your email address will not be published.

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