You are here: Home / Topics / How to join the array elements into a String

How to join the array elements into a String

Filed under: PHP on 2022-11-17 06:45:06

The below program is to combine the array elements into a string with given delimiter using PHP join() function. The PHP echo statement is used to output the result on the screen. An array is a single variable which can store multiple values at a time. The PHP join() function is used to get a string by joining the elements of an array.

join() function in php 


Example

<!DOCTYPE html>
<html>
<body>

<?php
$arr = array("This", “is”, "good", "website.");
echo join(" ",$arr);
?>

</body>
</html>


Output

This is good website.
 

About Author:
D
Deepak Sahoo     View Profile
I am preparing for UPSC. My dream is to be IAS.