join() function in PHP
0 2272
Join() function of PHP is used to merge all array items into a single string. It is an inbuilt function of PHP. The working of this function is the same as the working of implode() PHP function.
The return type of this function is string means it always returns a string corresponding to a given PHP array.
Syntax:
join($separator, $array);
here,
- $separator is a separator which used to separate array items in resultant string.
- $array is a PHP array.
Example:
<?php $arr=array("Mango","Banana","Orange","Apple"); $str1=join(",",$arr); // join array items by comma $str2=join("-",$arr); // join array items by - $str3=join(" ",$arr); // join array items by space echo "$str1 <br>"; echo "$str2 <br>"; echo "$str3 <br>"; ?>
Output:
Share:
Comments
Waiting for your comments