We have given an array containing some array elements and the task is to join all the array elements to make a string. In order to do this task, we have the following methods in PHP:
Method 1: Using implode() Method: The implode() method is used to join an array of elements that are separated by a string. Joining can be done with or without separator.
string implode($separator, $array)
Method 2: Using join() Method: The join() method is used to join an array of elements that are separated by a string. Joining can be done with or without separator. The join() method is same as the implode() method.
string join($separator, $array)
- How to create an array for JSON using PHP?
- Create a web server and run PHP script on it using Raspberry Pi
- How to create admin login page using PHP ?
- How to create bullets using <li> elements ?
- How to create comma separated list from an array in PHP ?
- How to create an array with key value pairs in PHP?
- How to create a date with a set timezone without using a string representation?
- PHP | Separate odd and even elements from array without using loop
- Reset keys of array elements using PHP ?
- How to create directory with HTML button and PHP ?
- How to create a copy of an object in PHP?
- How to create singleton design pattern in PHP 5 ?
- PHP | Collator create() Function
- Why PHP script does not create a directory with 777 permissions ?
- How to create a PHP form that submit to self ?
- How to create optional arguments in PHP ?
- How to create static classes in PHP ?
- How to create default function parameter in PHP?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.