PHP join() Function

PHP join() Function is used to join array elements into string.
The join() function is an alias of the implode() function.

Syntax :

implode(separator,array);

PHP join() Function returns string with separator between two array elements.

Parameter Values,
 

PHP join() Function
Parameter Description
separator Optional. Join array elements with separator string.
Default value for separator is an empty string.
array Required. The array to join to a string.

Let's see below example to understand join() Function in details.

Example :

<?php
$arr = array('Learn','php','join()','function','by','aryatechno');
print_r($arr);
echo "<br> Join array element without separator :".implode($arr)."<br>";
echo "<br> Join array element by space :".implode(" ",$arr)."<br>";
echo "<br> Join array element by dash:".implode("-",$arr)."<br>";
echo "<br> Join array element by semicolon:".implode(";",$arr)."<br>";
echo "<br> Join array element by comma:".implode(";",$arr)."<br>";

?>

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

55032